M
Miguel
Hello,
I have recorded a macro that selects 1 cell (G4) and then the macro does a
variety of things (like copy and paste, refresh a pivot table, etc using that
number from G4). My question is I want the macro to select a range of cells
(not only G4) and select the first cell and do what the macro is supposed to
do, then select the next cell and let the macro do again, and so on. I know I
have to create a loop, but so far I have been unsuccselful. Is there a way to
create this loop? My macro is below:
Range("G4").Select
Selection.Copy
Sheets("Census Input").Select
Range("G2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G2").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("G2:G151")
Range("G2:G151").Select
Range("Q4").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveWindow.LargeScroll ToRight:=-1
Sheets("Summary").Select
Selection.Copy
Sheets("RVA").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Thanks!!!
I have recorded a macro that selects 1 cell (G4) and then the macro does a
variety of things (like copy and paste, refresh a pivot table, etc using that
number from G4). My question is I want the macro to select a range of cells
(not only G4) and select the first cell and do what the macro is supposed to
do, then select the next cell and let the macro do again, and so on. I know I
have to create a loop, but so far I have been unsuccselful. Is there a way to
create this loop? My macro is below:
Range("G4").Select
Selection.Copy
Sheets("Census Input").Select
Range("G2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G2").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("G2:G151")
Range("G2:G151").Select
Range("Q4").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
ActiveWindow.LargeScroll ToRight:=-1
Sheets("Summary").Select
Selection.Copy
Sheets("RVA").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Thanks!!!