Paste Problem

G

Guest

I had a problem of Borders disappearing when I Cut data from one area of a
worksheet and Pasting it somewhere else.

Someone just showed me how to create a macro that would display borders in
cells that would remain when I Cut data from one area and Paste somewhere
else.

***MACRO***

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range("B")
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
End With
End Sub

To get this to work name the range where the grids should be to B. You can
change the LineStyle, Weight, or ColorIndex to suit your needs.

**********

The problem I'm having now is that when I Cut the data and click on the area
I want to Paste it, the Paste option is unavaiable and so is the Undo.

However, when I display the Clipboard, the Paste All is available and when I
click that, the data paste where I want it and the Paste option becomes
available again on the Toolbar and I can Paste the data again and again. But
when I try Cut and Paste of some other data, the Paste option beomes
unavailable once again.

If I Cut from the worksheet with the Macro and go to paste that data in
another worksheet, it works.

What's going on???

HELP!!!
 
G

Guest

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if Application.CutCopyMode = False then
With Range("B")
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 55
End With
End With
End if
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top