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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

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