Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Loop Until Last Worksheet in Workbook

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Loop Until Last Worksheet in Workbook

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


" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Loop Until Last Worksheet in Workbook

Thanks so much.


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
Loop worksheets workbook [email protected] Excel Programming 1 July 19th 07 08:01 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Worksheet loop won't loop L. Howard Kittle Excel Programming 4 March 17th 06 12:56 AM
Workbook Loop Headache Turin[_4_] Excel Programming 1 August 23rd 05 10:42 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM


All times are GMT +1. The time now is 08:24 PM.

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

About Us

"It's about Microsoft Excel"