View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John[_88_] John[_88_] is offline
external usenet poster
 
Posts: 205
Default Shuffle through sheets in a loop?

Erikhs,

Try this:

Sub SheetsLoop()

Dim wkb As Workbook
Dim wks As Worksheet
Dim i As Integer

Set wkb = Application.ActiveWorkbook
For i = 1 To wkb.Worksheets.Count
Set wks = wkb.Worksheets(i)
If wks.Name < "Paste" Then
'Add your copy paste code here
Else
'Do nothing or add other code here
End If
Next i

End Sub

The above code checks the sheet name so you'll need to change the "Paste"
name to whatever you're clling your target sheet.

Hope that helps

Best regards

John



"erikhs" wrote in
message ...

Hi,

I would like to copy an identical selection from multiple sheets
automatically, and then pasting to another sheet. How can i code a loop
that shuffles through the sheets without knowing their names, and then
stopping when it reaches the "paste" sheet? Is there some kind of
numerical sheet "category" that i can use?


--
erikhs
------------------------------------------------------------------------
erikhs's Profile:
http://www.excelforum.com/member.php...o&userid=32788
View this thread: http://www.excelforum.com/showthread...hreadid=562405