Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default moving through sheets in a loop

You have i in quotes, which makes it a string - try it as

sheets(i).select

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default moving through sheets in a loop

Thank You!

" wrote:

You have i in quotes, which makes it a string - try it as

sheets(i).select


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Data between sheets in the same workbook and moving data between Workbooks. Alison Brown Excel Worksheet Functions 0 February 10th 09 01:03 AM
Loop in sheets al007 Excel Programming 4 November 28th 05 03:07 PM
Loop through sheets michael Excel Programming 2 September 8th 04 02:52 PM
Moving through sheets Keith Emery Excel Programming 2 June 22nd 04 01:53 PM
Loop across Sheets and number of sheets Raj[_8_] Excel Programming 2 December 18th 03 09:18 AM


All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"