Change of Row event

C

crazybass2

I want to trigger an event when the row is changed as opposed to a cell. How
would I do this?

i.e.

I'm on row 12. I make a change to the B column, then tab to the C column.
After entering data in C, I tab over to F and enter more data. I don't want
the event to trigger until I click another row or hit the Enter key.
 
F

Frank Kabel

Hi
you would us ealso the worksheet_change event and check if anything
within your row is changed.
 
C

crazybass2

I've already got a worksheet_change event in my code. How would I check if
the row has changed since the last entry?
 
F

Frank Kabel

Hi
you could check with
if not intersect(target,me.range("1:1")) is nothing then
msgbox "change in row 1"
end if
 
C

crazybass2

That statement triggers only when in row 1 and regardless of whether I change
rows.

I need something that will trigger ONLY when I change rows.

For example.

Enter data at A1, tab (no event triggered), enter data at B1, tab(no event
triggered), enter data at C1, enter (event triggers here)
 
C

crazybass2

I mean that I don't want the event to trigger while I'm in the same row.

Starting at Cell A1. I want the event to trigger only when I move to a row
other than 1, (eg A2, A3, A4...etc.)

I don't want the event to trigger if I move from one column to the other
(A1, B1, C1, D1....ect)
 
F

Frank Kabel

Hi
this would require the SelectionChange event and storing the old row in
a static variable. Not fully tested but try the following then:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static iOldRow As Long
If Target.Cells.Count > 1 Then Exit Sub

If iOldRow < 1 Then
iOldRow = Target.Row
ElseIf iOldRow <> Target.Row Then
MsgBox "new row selected: " & Target.Row
iOldRow = Target.Row
End If
End Sub
 
Top