VBA: IF... Or... Or... And... Then?

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,760
Office Version
  1. 365
Platform
  1. Windows
I'm stuck with an IF statement but I just can't get it right:

What I'm trying to write is IF Range("D2").value is either "H", "N", "P" or "R" or if Range("H2").value is less than 7999 or between 22100 and 26500 Then...

I know how to write the first part (= all the OR's) but how can I add the last one (= Or (Range("H2").value >22100 And Range("H2").value<26500) to the IF statement?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Perhaps like this

Code:
If IsNumber(Application.Match(Range("B2").Value, Array("H", "N", "P", "R"), 0)) And (Range("H2").Value < 7999 Or (Range("H2").Value >= 22100 And Range("H2").Value <= 26500)) Then
 
Upvote 0

Forum statistics

Threads
1,222,908
Messages
6,168,967
Members
452,228
Latest member
just4jeffrey

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