Help with VBA, or maybe vanilla Excel function?

Z

Zilla

I want to tabulate a From->To places list
to signify trips FromA->ToB.

Say I have col A validated against a list that
signifies the "From". Col B is also validated
with the same list, that signifies the "To".
Obviously, I don't want Col A and Col B
be the same value for the same row since
FromA-ToA does not make sense.

How can I do this in VBA, or vanilla Excel?
 
T

Toppers

Right Click tab on worksheet where your data is entered, "view code" and
copy/paste this code. Assumes entries are in Columns A & B.

HTH


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit
Application.EnableEvents = False
If Target.Column < 3 Then
If Cells(Target.Row, "A") = Cells(Target.Row, "B") Then
MsgBox "To/From cannot be same location"
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub
 
Top