Change of Row event

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

Guest

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.
 
Hi
you would us ealso the worksheet_change event and check if anything
within your row is changed.
 
I've already got a worksheet_change event in my code. How would I check if
the row has changed since the last entry?
 
Hi
you could check with
if not intersect(target,me.range("1:1")) is nothing then
msgbox "change in row 1"
end if
 
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)
 
Hi
so you may explain what you mean with 'then I change rows'
 
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)
 
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
 

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