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
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,196
Something like...

If Range("B2") = "Finance" or range("myOtherRange")="X"
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hello and welcome to MrExcel.

The syntax is

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

Mike Blackman

Well-known Member
Joined
Jun 8, 2007
Messages
2,494
Hi,

Does this help;

Code:
If Range("B2") = "Finance" And Range("B3") <> "Finance" Then
 

Watch MrExcel Video

Forum statistics

Threads
1,122,371
Messages
5,595,782
Members
414,020
Latest member
Meghdad

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
Top