Trapping Worksheet Target

C

Chuck Taylor

I'm using the Worksheet.Change function to trigger a macro when a cell
changes. I'm specifying the right cell (Target.Address = $Col$Row)
but I can't get the darn thing to trigger. I want to see what address
is being passed in the If Target.Address.... line.

Using a breakpoint doesn't seem to work. Any ideas?
 
M

mudraker

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i
Dim c
Dim a
i = Target.Row
c = Target.Column
a = Target.Address

End Sub
 
C

Chuck Taylor

On Fri, 5 Dec 2003 07:41:25 -0000, "Nigel"
Thanks for the tip. I don't know what I'm doing but the behavior of
the worksheet_change is really strange.

I'll put a breakpoint in the "If Target.address = $x$y" line and it
will never get triggered although I know the $x$y cells are changing.
That's really the problem I have - even with a breakpoint, I can't get
the breakpoint to ever be executed (so I can examine the
target.address).

Sometimes, however, it triggers all the time despite the
"Application.Eventenable=false" line I put in before calling the
macro. I'll hit break to stop the execution and then examine the
target.address from the debug line and it will have an address that
has no relation to what I'm doing.

I just can't get consistent execution.
 
J

James Cox

Since you asked for "any ideas", an untested one would be to use a message
box in the sub to display the target address.

Let us know if this works!

James Cox
 
Top