Repeat Macro

Houli

New Member
Joined
Jul 14, 2011
Messages
3
This should be an easy one. I want to repeat this macro until the active cell is empty. For instance, right now the macro is placing the active cell (Ref!RC[-2]) in cell "C2". Now I want this whole macro to start over and place Ref!RC[-3] in cell "C2". I would this to repeat until the active cell or blank or thru a set range, whichever option is easier.

Sub RunSave()
'
' RunSave Macro
'
'
Range("C2").Select
ActiveCell.FormulaR1C1 = "=Ref!RC[-2]"
Dim cell As Range
For Each cell In Range("T10:T44")
If UCase(cell.Value) = 1 Then
cell.EntireRow.Hidden = True
End If
Next
ThisFile = Range("C2").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
Rows("1:949").Select
Selection.EntireRow.Hidden = False
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try

Code:
Sub RunSave()
'
' RunSave Macro
'
'
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("C2:C" & LR).FormulaR1C1 = "=Ref!RC[-2]"
Dim cell As Range
For Each cell In Range("T10:T44")
If UCase(cell.Value) = 1 Then
cell.EntireRow.Hidden = True
End If
Next
ThisFile = Range("C2").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
Rows("1:949").Select
Selection.EntireRow.Hidden = False
End Sub
 
Upvote 0
Thanks, but that's not exactly what I was looking for. That suggestion takes the next active cell and places it in cell C3, C4, etc. I need the macro to after the workbook has saved replace cell C2 with the next active cell...and continue this loop until the active cell is blank.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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