paste and paste special greyed out

methody

Well-known Member
Joined
Jun 17, 2002
Messages
857
Hello there

The paste and paste special options are greyed out on a reasonably complex workbook which I am using.

I have managed to isolate the problem to the piece of code below. The code makes the colour of a selected cell change colour. can anyone explain why this code remove these options and can anyone suggest how to adjust the code so that the paste and paste special options are not greyed out.
thanks

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim nm As Name, rng As Range
On Error Resume Next
Set nm = ThisWorkbook.Names("CellAddress")
On Error GoTo 0
Set rng = Intersect(Target, Range("I15:I588"))
If Not nm Is Nothing Then nm.RefersToRange.Interior.Color = vbDarkBlue
If Not rng Is Nothing Then
If rng.Count = 1 Then
On Error Resume Next
nm.Delete
On Error GoTo 0
ThisWorkbook.Names.Add "CellAddress", rng
rng.Interior.Color = vbRed
End If
End If

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This line:

If Not nm Is Nothing Then nm.RefersToRange.Interior.Color = vbDarkBlue

clears the clipboard (if the interior colour is set).
 
Upvote 0
thank you
Is there anyway of retain the retaining the ability to change the cell colour without having the options greyed.
 
Upvote 0
I don't think so. I don't know a way to establish what was on the clipboard so that it could be put back there.
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top