LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Can a For statement work in reverse (from 40 to 1)

Is there a way to use a For statement in reverse?
For example:

For i = Sheets.Count To 4
Sheets(i).Activate
Next i

Instead of starting at sheet 4 and working up to the number of sheets in the
workbook, I'd like to start on the last sheet of the workbook and work back
to sheet 4. Is this possible?

The reason I want to do this is because based on certain criteria, I may be
deleting that sheet. Once that happens the sheet numbers get thrown off and
I end up missing some sheets and then possibly getting an error near the end
of the code when it tries to view sheets that don't exist.

Thanks in advance.
Paul


--



 
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
Help - If statement will not work Randy Mis Excel Worksheet Functions 1 January 29th 11 11:48 PM
if then statement... can't make it work:S sed Excel Discussion (Misc queries) 6 October 15th 08 02:07 PM
I can not seem to get my IF / AND statement to work, help please petester Excel Discussion (Misc queries) 3 October 15th 07 05:29 PM
Why doesn't this nested IF statement work? Brandoni Excel Worksheet Functions 4 April 19th 06 10:26 PM
This statement does not work in VB Tod Excel Programming 5 October 22nd 04 06:13 PM


All times are GMT +1. The time now is 06:57 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"