An If Question in VBA

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
I've wrote this to check a cell for one of two words. It will look for one word, but how do I make it look for either word? Calc being a macro! Am I on the right track?

If Range("B1").Value = "First" Then Calc
If Range("B1").Value = "Second" Then Calc
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
in spreadsheet in C1 type
=if(or(B1="first",b1="second" ),"yes","no")

in vba
if range("B1")="first" or range("B1")="second" then
.................
....................
 
Upvote 0
No need for the formula in C1. Simply use the following code:

Code:
If Range("B1").Value = "First" or Range("B1").Value = "Second" Then Calc
 
Upvote 0
Thanks

A big thank you to both of you who offered help. It works perfectly.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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