ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Help with VBA, or maybe vanilla Excel function? (https://www.excelbanter.com/excel-worksheet-functions/134934-help-vba-maybe-vanilla-excel-function.html)

Zilla[_2_]

Help with VBA, or maybe vanilla Excel function?
 
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?

--
- Zilla
(Remove XSPAM)



Toppers

Help with VBA, or maybe vanilla Excel function?
 
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

"Zilla" wrote:

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?

--
- Zilla
(Remove XSPAM)





All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com