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: 2
Default for next loops in visual basic excel

Hi,

I wonder if anyone can explain the following. When I have a very
simple for next loop, for example:

for i=1 to worksheets.count
sheets(i).select
activesheet.name="a" & i
next i

the first time the macro goes through the loop, when you would expect
the value of i to be 1, the value of i is the highest value, i.e.
worksheets.count.

By the way, it does not seem to be consistent. If I stop and restart
the macro, it seems to go through the loop correctly i.e with i
starting from 1.

Can anybody explain how this works to me?

Thanks!
 
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
Excel and its Visual Basic IDE TJMonti Excel Discussion (Misc queries) 0 April 20th 09 04:14 PM
Programmatic access to visual basic project via Visual FoxPro Jim Rech Excel Programming 0 January 11th 07 01:53 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM


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