View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Knox Knox is offline
external usenet poster
 
Posts: 45
Default moving through sheets in a loop

I have a loop that moves through sheets as "i" changes in a loop. I have
sheets named 1,2,3,4,5 etc. For some reason when I run this I get an error
saying the subscript is out of range for the last line below:

Dim i As Long
Dim startWS As Worksheet
Dim startRange As Range

Set startWS = ActiveSheet
Set startRange = Selection

For i = 3 To 12


startRange.AutoFilter Field:=3, Criteria1:=CStr(i)
Selection.AutoFilter Field:=7, Criteria1:="Monday"
Cells.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("i").Select

Any suggestions? thank you!