majinvegito123
New Member
- Joined
- Oct 19, 2022
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hi guys. I'm trying to make it so I can ensure that a particular set of values that are user-entered MATCH a list that I have off to the right or else the code is supposed to error out and send a message saying it's invalid and try again.
I have a spot for four entries. They are labelled BuyOne, BuyTwo, BuyThree, BuyFour and I need them to match a list that is generated via SQL in Column O (This list can change at any time either smaller or larger, so it's variable). The list in Column O is labelled as "Query_Buyer"
I need this done via VBA but I can't quite figure out how to properly do the check. Here's what I've got so far. Keep in mind that it doesn't work and I get a type mismatch.
Can anyone help me figure out what's going on?
I have a spot for four entries. They are labelled BuyOne, BuyTwo, BuyThree, BuyFour and I need them to match a list that is generated via SQL in Column O (This list can change at any time either smaller or larger, so it's variable). The list in Column O is labelled as "Query_Buyer"
I need this done via VBA but I can't quite figure out how to properly do the check. Here's what I've got so far. Keep in mind that it doesn't work and I get a type mismatch.
VBA Code:
If Range("BuyOne") = vbNullString Or Range("BuyOne") = Range("O1:O50") Then
MsgBox "Invalid Buyer Code.."
Range("BuyTwo").Select
Else: End If
If Range("BuyTwo") = vbNullString Or Range("BuyTwo") = Range("O1:O50") Then
MsgBox "Invalid Buyer Code.."
Range("BuyTwo").Select
Else: End If
If Range("BuyThree") = vbNullString Or Range("BuyThree") <> Range("O1:O50") Then
MsgBox "Invalid Buyer Code.."
Range("BuyThree").Select
Else: End If
If Range("BuyFour") = vbNullString Or Range("BuyFour") <> Range("O1:O50") Then
MsgBox "Invalid Buyer Code.."
Range("BuyFour").Select
Else: End If
Can anyone help me figure out what's going on?