ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   can OnEntry be limited to certain cells only?? (https://www.excelbanter.com/excel-programming/354391-can-onentry-limited-certain-cells-only.html)

Chief Wiggums[_2_]

can OnEntry be limited to certain cells only??
 

I can use OnEntry to trigger a macro when any cell on a given sheet is
edited --

Sub Auto_Open()
Worksheets("Sheet1").OnEntry = "TriggeredMacro"
End Sub

Is there a way to limit the triggering to just certain cells? so that
only editing in those cells initiates the macro?:confused:

Thanks in advance ...


--
Chief Wiggums
------------------------------------------------------------------------
Chief Wiggums's Profile: http://www.excelforum.com/member.php...o&userid=16934
View this thread: http://www.excelforum.com/showthread...hreadid=516531


Jim May

can OnEntry be limited to certain cells only??
 
example from Help:

Worksheets("Sheet1").Activate
Set isect = Application.Intersect(Range("rg1"), Range("rg2"))
If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If




"Chief Wiggums"
wrote in message
news:Chief.Wiggums.23sqla_1140889801.4844@excelfor um-nospam.com...

I can use OnEntry to trigger a macro when any cell on a given sheet is
edited --

Sub Auto_Open()
Worksheets("Sheet1").OnEntry = "TriggeredMacro"
End Sub

Is there a way to limit the triggering to just certain cells? so that
only editing in those cells initiates the macro?:confused:

Thanks in advance ...


--
Chief Wiggums
------------------------------------------------------------------------
Chief Wiggums's Profile:
http://www.excelforum.com/member.php...o&userid=16934
View this thread: http://www.excelforum.com/showthread...hreadid=516531




Chief Wiggums[_3_]

can OnEntry be limited to certain cells only??
 

Hmmm ... I'm think this involves the Caller property, which can somehow
be used to return the address of the cell whose editing triggered the
macro.

If I had that, then that could serve as Range("rg1") in the example
you've given
and it would work perfectly.

Thanks very much, Jim.


--
Chief Wiggums
------------------------------------------------------------------------
Chief Wiggums's Profile: http://www.excelforum.com/member.php...o&userid=16934
View this thread: http://www.excelforum.com/showthread...hreadid=516531


Chief Wiggums[_4_]

can OnEntry be limited to certain cells only??
 

OK, the following seems to work:

Set isect = Application.Intersect(Range(Application.Caller.Add ress),
Range("rg2"))
If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

In this example, Application.Caller.Address returns the address of the
cell which was edited. So one can test and then act, depending on
whether that cell was a specified cell or not.

THanks again, Jim.


--
Chief Wiggums
------------------------------------------------------------------------
Chief Wiggums's Profile: http://www.excelforum.com/member.php...o&userid=16934
View this thread: http://www.excelforum.com/showthread...hreadid=516531


Jim May

can OnEntry be limited to certain cells only??
 
Thanks for the feedback

"Chief Wiggums"
wrote in message
news:Chief.Wiggums.23surb_1140895201.7253@excelfor um-nospam.com...

OK, the following seems to work:

Set isect = Application.Intersect(Range(Application.Caller.Add ress),
Range("rg2"))
If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

In this example, Application.Caller.Address returns the address of the
cell which was edited. So one can test and then act, depending on
whether that cell was a specified cell or not.

THanks again, Jim.


--
Chief Wiggums
------------------------------------------------------------------------
Chief Wiggums's Profile:
http://www.excelforum.com/member.php...o&userid=16934
View this thread: http://www.excelforum.com/showthread...hreadid=516531





All times are GMT +1. The time now is 12:39 PM.

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