Retain clipboard during macro run

Jubjab

Well-known Member
Joined
Jan 3, 2007
Messages
995
I have a workbook with a small macro routine on sheet1 that is run on a Worksheet_activate event. This clears the clipboard, meaning it is impossible to paste anything into the sheet.

Any ideas on how to make pasting possible?

PS. The macro needs to run as soon as the worksheet is activated, so a worksheet_change event is out of the question.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What is you macro doing that clears the clipboard?

It colors a range of cells (creating a heat map). Here is the entire code:
Code:
Private Sub Worksheet_Activate()
            For Each c In Range("I5:K73,I78:K157,I162:K191,I193:K213,I215:K245,I249:K277")
                Select Case c.Value
                
                Case 0
                    c.Interior.ColorIndex = 10
                Case Is >= 100
                    c.Interior.ColorIndex = 52
                Case Is >= 24
                    c.Interior.ColorIndex = 12
                Case Is >= 12
                    c.Interior.ColorIndex = 43
                Case Is >= 9
                    c.Interior.ColorIndex = 6
                Case Is >= 6
                    c.Interior.ColorIndex = 36
                Case Is >= 5
                    c.Interior.ColorIndex = 9
                Case Is >= 4
                    c.Interior.ColorIndex = 7
                Case Is >= 3
                    c.Interior.ColorIndex = 38
                Case Is >= 2
                    c.Interior.ColorIndex = 35
                Case Is >= 1
                    c.Interior.ColorIndex = 4
                Case Is < 1
                    c.Interior.ColorIndex = 50
                Case Else
                    c.Interior.ColorIndex = 2
                End Select
            Next c
            
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

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