Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Increment variable not incrementing?

I have a series of loops that utilize the same set of variables
as integer increments...

For i = 1 to 100
For j = 1 to 200
..
..
..
Next j
Next i
For i = 1 to 500
..
..
..


The odd thing is that when it hits the subsequent use of the variable
in next set of for/next loops, the variable is not resetting to the
value called for in the loop. What I see happening is that its starting
off at 1+ the top value of the prior loop. So in this instance, it
would start at 101 and go to 500.

Thoughts?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Increment variable not incrementing?

Actually - its worse than I thought -

Now when I "watch" the process - its plowing right through the For-Next
loops without looping at all.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Increment variable not incrementing?

This works, need to change numbers
Sub Macro7()
For i = 1 To 2
For j = 1 To 2
Stop
Next j
Stop
Next i
End Sub


" wrote:

I have a series of loops that utilize the same set of variables
as integer increments...

For i = 1 to 100
For j = 1 to 200
..
..
..
Next j
Next i
For i = 1 to 500
..
..
..


The odd thing is that when it hits the subsequent use of the variable
in next set of for/next loops, the variable is not resetting to the
value called for in the loop. What I see happening is that its starting
off at 1+ the top value of the prior loop. So in this instance, it
would start at 101 and go to 500.

Thoughts?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Increment variable not incrementing?

Actually, it was a much different problem.

What I discovered was that I had dim'd the counters as Integers, but on
one occasion,
it just happened the upper bound of the 2nd use of the counter happened
to be larger than 32,767 (the upper limit of an integer) and so the
code was just pushing through the For Next loop ignoring the For and
the Next. Once I changed the Integer statement to Long, it worked fine.

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
incrementing paul/bones[_2_] Excel Worksheet Functions 2 September 12th 07 01:54 PM
Variable Incrementing John Excel Discussion (Misc queries) 3 May 12th 06 10:16 PM
Increment a Variable Defined Date by 1 day JimI Excel Programming 2 October 12th 04 12:57 AM
Increment a variable Harry[_3_] Excel Programming 0 April 9th 04 04:06 PM
Increment a variable while looping ibeetb Excel Programming 2 September 25th 03 07:15 PM


All times are GMT +1. The time now is 07:11 AM.

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"