Vba Condense Multiple OR

Eisasuarez

Well-known Member
Joined
Mar 23, 2012
Messages
653
Hi All

How can i have a vba code to consense multiple or criterias

Say i wanted to check to see

If txtboxtest.value <> "Name1" or txtboxtest.value <> "Name2" etc... (There could be multiple Names to check for)
How can i condense this rather than writing multiple or statements?

P.s i could also have a range set up on say sheets Access Range A2 to last row therefore i coukd say if the txtboxtest.value <> (In that range list) then do what ever but im stuck how to condense this?

Would i need a loop?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
So how would i do this to say if the the value is in the access list then you have access else you dont

E.g I have a named range called access on the access sheet

Code:
SELECT CASE textboxName.value
      CASE IS (IN THE ACCESS RANGE LIST
             MSGBOX "YOU HAVE ACCESS"
CASE ELSE
MSGBOX "YOU DONT HAVE ACCESS"
END SELECT
 
Upvote 0
Code:
If Not Iserror(application.match(textboxName.value, sheets("access").range("access"), 0)) then
msgbox "You have access"
Else
Msgbox "You don't have access"
End If

for example.
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,264
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top