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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,669
Messages
5,838,685
Members
430,563
Latest member
Raeyven

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