Worksheet Change Event when pasting multiple rows/columns

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
I'm trying to have code run when data is pasted into a worksheet. I have this code on the Sheet page, but it doesn't work if the data is pasted. I have to go specifically to only A1, and copy/paste. Thanks.



Private Sub Worksheet_Change(ByVal Target As Range)




If Target.Address = "$A$1" Then Call Marco1



End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hello Helpexcel,

Are you intending to use any cell in Column A only for data entry to activate the code?

Cheerio,
vcoolio.
 
Upvote 0
I would suggest using Double click and specify the range

In this example:

Enter the value One into Range("A1")

And when you double click on Range("A1") The Macro named One will Run
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" Then
Cancel = True
Application.Run Target.Value
End If
End Sub
 
Upvote 0
If you copy a single cell and paste it into A1, then Target.address = "A1", but if you paste several cells, then in target you have a range of cells. To know if any of those cells in the range of Target contains cell A1, it could be like this:


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("$A$1")) Is Nothing Then
        Call marco1
    End If
End Sub
 
Upvote 0
Thanks, but I'm not having any luck with those. Row 1 A:H will always be pasted over, so i figured i could just use A1 as the trigger.
 
Upvote 0
There are two scripts provided here that should do what you want.

So are you saying when you double click on A1 Nothing happens



Or if you make a manual change to A1 nothing happens
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

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