E
EWR
I am trying to execute a macro for all the rows which a user pastes a value
into. For example, the user selects cells AJ94, AJ108, AJ120 and pastes a
copied value.
The problem is that the msgbox returns $AJ$94 3 times.
I have (excuse any mistakes I have...I cut a whole bunch of junk)
Any thoughts?
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = True
Dim DataRng, TrgtRng As String
Dim rng, c As Range
DataRng = ActiveWorkbook.Names("trgtrng").RefersToRange.Address
‘trgtrng refers to column AJ in the example
If Not Application.Intersect(Target, Range(DataRng)) Is Nothing Then
TrgtRng = Target.AddressLocal()
Set rng = Range(TrgtRng)
For Each c In trng
MsgBox ActiveCell.AddressLocal()
Next c
Endif
End Sub
into. For example, the user selects cells AJ94, AJ108, AJ120 and pastes a
copied value.
The problem is that the msgbox returns $AJ$94 3 times.
I have (excuse any mistakes I have...I cut a whole bunch of junk)
Any thoughts?
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = True
Dim DataRng, TrgtRng As String
Dim rng, c As Range
DataRng = ActiveWorkbook.Names("trgtrng").RefersToRange.Address
‘trgtrng refers to column AJ in the example
If Not Application.Intersect(Target, Range(DataRng)) Is Nothing Then
TrgtRng = Target.AddressLocal()
Set rng = Range(TrgtRng)
For Each c In trng
MsgBox ActiveCell.AddressLocal()
Next c
Endif
End Sub