Multiple If Statements

mdsteury

New Member
Joined
Apr 7, 2016
Messages
10
Hello...new user...limited knowledge of VBA. Here's my question...I have a macro started like this:

Range("S5").Select
ActiveCell.Value = ActiveCell.Value + 1
Range("U5").Select
ActiveCell.Value = ActiveCell.Value + 1
Range("M2").Select
If H1 = 1 Then ActiveCell.Value = ActiveCell.Value + 2

However I would like to do the same for N2 if H1 = 2, and for O2 if H1 > 2. Can someone help please?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Welcome to the board. As you gain experience, you'll see very little use of .Select or .Activate.

Based on the above code and your comments, try:
Code:
Range("S5").Value = Range("S5").Value + 1
Range("U5").Value = Range("U5").Value + 1

If Range("H1").Value = 1 Then
  Range("M2").Value = Range("M2").Value + 1
  Range("N2").Value = Range("N2").Value + 1
Else
  If Range("H1").Value > 1 Then
     Range("O2").Value = Range("O2").Value + 1
  End If
End If
Lots of ways to make above more efficient, but for now it should suffice; hope it works.
 
Upvote 0
Solution
Thank you! This worked beautifully. I use Excel to do stat keeping for a community basketball league, and I have started to make some improvements in the offseason.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,548
Members
449,170
Latest member
Gkiller

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