AND IF Macro

akvanden

New Member
Joined
Mar 30, 2009
Messages
24
Hi all,

Having some issues trying to figure out how to use the If statements when I need to have two or more conditions met. I need the conditions to say when the range equals 'Finance' AND when another range equals say 'X'. I've been searching all over the net and this site and cannot find what I need so I must be searching wrong - hoping the expertise on this site can help.

Thanks!



Sub Macro1()

Dim RetVal
If (Range("B2") = "Finance") Then
Sheets("Manual Bridge").Activate
Range("A1").Select
Else
Sheets("Pull Bridge").Activate
Range("A1").Select
End If
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Something like...

If Range("B2") = "Finance" or range("myOtherRange")="X"
 
Upvote 0
Hello and welcome to MrExcel.

The syntax is

Code:
If Range("B2").Value = "Finance" And Range("C2").Value = "Income" Then
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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