if cell ="",then this macro, repeat all rows

rnation

New Member
Joined
Mar 18, 2010
Messages
7
I am trying to get a macro to run base on the cell value, then go to the next row and potentially run a different macro. Here is the code, please help.

Sub Update()
Range("AU2").Select

For i = 1 To Selection.CurrentRegion.Rows.Count + 1

If ActiveCell.FormulaR1C1 = "s" Then
Run (["if_s"])
End If

If ActiveCell.FormulaR1C1 = "b" Then
Run (["if_b"])
End If

If ActiveCell.FormulaR1C1 = "" Then
Run (["ifnothing"])

End If

If ActiveCell.FormulaR1C1 = "q" Then
Run (["q"])
End If

If ActiveCell.FormulaR1C1 = "w" Then
Run (["w"])
End If

i = i + 1
Next i

End Sub
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,039
you havent changed your selection, which your code requires, although really you don't want to...

replace activecell with say activecell.offset(i,0), this will look at each cell that is i rows from your active cell (which in this case is the selected cell)

try this instead:

dim cl as range
for each cl in Range(cells(2,47):cells(100,47))
select case cl.value
case "s"
if_s
case "b"
if_b
etc
end select
 

Watch MrExcel Video

Forum statistics

Threads
1,122,709
Messages
5,597,697
Members
414,164
Latest member
ARTW

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