Paste disabled when using SelectionChange

ChgsAllAround

New Member
Joined
Apr 11, 2008
Messages
36
I am using the worksheet_selectionchange macro. I noticed that if you refer to any other cell than the one that is the "target" cell, the Paste option is greyed out. This means that for the person using the worksheet, paste is never available. Is there a way of getting around this? I've tried both direct code inside of the macro and calls to other subs--neither works. I'm guessing that it's related to the fact the the macro is essentially using the excel clipboard to keep track of the content of the target, but that's not very helpful to the end-user. Any suggestions? Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Put some code in your event that restricts it from doing anything outside your target range...

Like if you only want the event code to run if the target cell is within column C

Then make this the first line of your event code.

If Intersect(Target,Range("C:C")) Is Nothing Then Exit Sub

Now, the event code will only run if the user selects a cell in column C
that should help..
 
Upvote 0
Thank you. My problem is that I NEED to refer to cells other than the target in this macro. For example, Col A and Col B have dates. Col C is colored depending on how far apart the dates fall. So...the user changes a date, hits enter, and the macro activates to check for time span.

"WhichColor" is a custom function that uses a case statement to return the proper ColorIndex

For i = 1 to 5
Range("C" & i).Interior.ColorIndex = WhichColor(Range("A" & i).Value, Range("B" & i))
Next i

Any more ideas on how to reference other cells in this macro and still have paste available?
 
Upvote 0
It will still be able to "Refer" to other cells.

That code will just restrict the code to be TRIGGERED by column C being selected. so it doesn't run if OTHER cells are changed..
 
Upvote 0
AFAIK the event code being called will clear the clipboard. One solution would be to paste the clipboard elsewhere (perhaps to a hidden sheet) then to grab it back again within the event procedure.
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

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