I have a routine that I am trying to streamline by using a loop. I have never worked with loops before so I could use some help.
Here is my code:
Here is my code:
Code:
Sheets("GLD").Select
Rows("2:2").Select
[ActiveWindow.FreezePanes = True
Columns("A").Select
With Selection
.NumberFormat = "mm/dd/yyyy"
.Columns.Autofit
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
Columns("B:E").Select
With Selection
.NumberFormat = "0.00"
.Columns.Autofit
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
Columns("F").Select
With Selection
.NumberFormat = "#,##0"
.Columns.Autofit
.VerticalAlignment = xlCenter
.HorizontalAlignment = xlLeft
End With
R1 = ActiveSheet.UsedRange.Rows.Count
R2 = "F" & R1
SR = R1 - 22
ActiveWindow.ScrollRow = SR
Range(R2).Select
This particular excel file has 10 worksheets in it. Currently I have repeated this code ten times with the different sheet names on the top. Is there a way to loop through all the worksheets using the same code? Any help woould be appreciated. This is my first time posting so if I have done something wrong please advise.