ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   worksheet change based on target range (https://www.excelbanter.com/excel-programming/418389-worksheet-change-based-target-range.html)

J.W. Aldridge

worksheet change based on target range
 


Want to automatically run macro if range within worksheet is changed
in any way.

Range is L15:L1000.

Maco name is "stank".

Please assist....

Thanx

JLGWhiz

worksheet change based on target range
 
This assumes that stank is in the standard code module1 and that this code
will be put into the applicable sheet code module.

Private Sub Worksheet_Change(ByVal target As Range)
Set sRng = Range("L15:L1000")
If target = Intersect(target, sRng) Then
stank
End If
End Sub




"J.W. Aldridge" wrote:



Want to automatically run macro if range within worksheet is changed
in any way.

Range is L15:L1000.

Maco name is "stank".

Please assist....

Thanx


Peter T

worksheet change based on target range
 
Suggest change

If target = Intersect(target, sRng) Then

to
If Not Intersect(target, sRng) Is Nothing Then

Regards,
Peter T


"JLGWhiz" wrote in message
...
This assumes that stank is in the standard code module1 and that this code
will be put into the applicable sheet code module.

Private Sub Worksheet_Change(ByVal target As Range)
Set sRng = Range("L15:L1000")
If target = Intersect(target, sRng) Then
stank
End If
End Sub




"J.W. Aldridge" wrote:



Want to automatically run macro if range within worksheet is changed
in any way.

Range is L15:L1000.

Maco name is "stank".

Please assist....

Thanx




JLGWhiz

worksheet change based on target range
 
Probably less likely to throw an Oject Variable Not Set error that way.
Thanks Pete.

"Peter T" wrote:

Suggest change

If target = Intersect(target, sRng) Then

to
If Not Intersect(target, sRng) Is Nothing Then

Regards,
Peter T


"JLGWhiz" wrote in message
...
This assumes that stank is in the standard code module1 and that this code
will be put into the applicable sheet code module.

Private Sub Worksheet_Change(ByVal target As Range)
Set sRng = Range("L15:L1000")
If target = Intersect(target, sRng) Then
stank
End If
End Sub




"J.W. Aldridge" wrote:



Want to automatically run macro if range within worksheet is changed
in any way.

Range is L15:L1000.

Maco name is "stank".

Please assist....

Thanx






All times are GMT +1. The time now is 01:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com