R
rob nobel
The following bit of code is my attempt to test if data has been entered in
2 columns, but when the next cell selected is not in the same row, ie. if
another cell is selected outside that row, by mouse or keyboard (enter or
arrows, etc), it doesn't work too well.
How can this be accomplished so that as soon as an amount is entered in
either of the two columns "H" or "I", that the data in the other column is
deleted (if there is any) & that the message appears after deleting the
other column's data.
I notice that fiddling around with trying to do this, that calculation time
is increased quite a bit, even for cells that aren't directly related to
this test. So I would like to have a procedure that strictly only tests
those two columns, if possible.
Please help.
Rob
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.Cells(Target.Row, "H") And Me.Cells(Target.Row, "I") <> "" Then
MsgBox "You cannot enter an amount for both credit and debit. Please correct
before proceeding."
ActiveCell.ClearContents
End If
2 columns, but when the next cell selected is not in the same row, ie. if
another cell is selected outside that row, by mouse or keyboard (enter or
arrows, etc), it doesn't work too well.
How can this be accomplished so that as soon as an amount is entered in
either of the two columns "H" or "I", that the data in the other column is
deleted (if there is any) & that the message appears after deleting the
other column's data.
I notice that fiddling around with trying to do this, that calculation time
is increased quite a bit, even for cells that aren't directly related to
this test. So I would like to have a procedure that strictly only tests
those two columns, if possible.
Please help.
Rob
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.Cells(Target.Row, "H") And Me.Cells(Target.Row, "I") <> "" Then
MsgBox "You cannot enter an amount for both credit and debit. Please correct
before proceeding."
ActiveCell.ClearContents
End If