Loop Until Last Worksheet in Workbook

D

derrick.perkins

Hi,

As part of a more complex script, I want this loop to do a set of
actions and then move to the next sheet and preform the same set of
actions and then stop on the last sheet.

Here is what I have so far:

Sub Test
ActiveSheet.Next.Select
Do
<my series of code is here>
ActiveSheet.Next.Select
Loop
End Sub

It is working so far, but when I get to the end an error pops up. Not
a big deal, just don't want to have it.

Thanks in advance for your help,
Derrick
 
G

Guest

Sub Test
ActiveSheet.Next.Select
Do
<my series of code is here>
if ActiveSheet.Index <> Sheets.count then
ActiveSheet.Next.Select
else
exit do
End if
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top