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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,216,586
Messages
6,131,585
Members
449,657
Latest member
Timber5

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