What cell caused the worksheet change event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to run a routine on my worksheet when the change event happens. This
event requires me to know the row and column of the cell that was changed,
but if the user pressed return to complete the entry them the cursor moved
down the the next row and if they press the Tab key it moves to the next
column.

Is there any way to find out which cell was changed?
 
Worksheet_Change has one argument and that is Target which is the range that
was changed so this should work for you...

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Column & " - " & Target.Row
End Sub

You might be thinking of selection change where target returns the currently
selected range.
 
you can set the last range to a static value

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
Static OldRange As Range
dim i as integer
dim j as integer

if not OldRange is nothing then
i = OldRange.row
j = OldRange.column
end if

set OldRange = Target

End Sub
 
Ignore my post I thought you were asking about the SheetSelectionChange
event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top