VBA - using OR (or a logical equivalent)

Chris The Rock

Active Member
Joined
Feb 24, 2002
Messages
287
My brain is fried. Between VBA and SQL, sometimes I can't remember how to do certain things, like this:

I want to set a boolean variable = TRUE if any of the following conditions are met:
IF a cell's value contains "PCT" ,
OR
IF that cell's value contains "%",
OR
IF that cell's value contains "PERCENT"

I know how to use INSTR to find out if a string is found in another string, I just can't wrap my head around using 3 criteria. Sounds like the perfect time to use SELECT CASE, but I can't think of how it should go.

Here's how I'd code it if I only was looking for a single one of these criteria:
Code:
If InStr(1, UCase(rng_NewTarget.Value), "PCT") <> 0 Then
    bln_IsPCT = True
End If

Can I use "OR", like in SQL? Or is there a smarter way to do this?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I found a way to do this. Kinda clever. Anyone who digs this up in a search, just ask me and I'll tell you how I did it.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

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