'Do Until...' Restart
Hi Jack,
I am trying to understand the logic here.
If A1 is less than 100 (i.e. there are less than 100 entries in B1:B500 that
equal 15), the macro will loop. In that looping are some random actions that
will eventually add the number 15 to the B1:B500 range enough times that cell
A1 will equal or exceed 100.
When that happens, you want the Do Until loop to end.
But then it looks like you are asking for the Do Until loop to restart. How
can it restart if A1 =100?
What am I missing?
--
Ken Hudson
"Jack" wrote:
Hi All,
Thanks for all the replies - but maybe I should start from scratch and
explain the question in, hopefully, a clearer way [ sorry if I confused
everyone]
In A1 I have '=Countif(B1:B500,15)'
The integer values in cells B1:B500 get incremented with each sheet recalc
due to random functions elsewhere in the sheet and therefore A1 is
incremented randomly with each recalc.
The macro is required to recalculate the sheet until A1 = 'exactly' 100. -
i.e when there are exactly 100 cells in B1:B500 with a value of 15.
So I wrote
Do Until Range("a1") = 100
' Do Stuff
Calculate
Loop
The problem is that A1 can be incremented in irregular steps - e.g. from 1
to 2 to 6 etc. and from 93 to 94 to 99 to 102 etc. and therefore a1=100 is
never true - hence a permanent loop
But I need to restart the Do Until loop if and when A1 exceeds 100.
[BTW I can handle the resetting of the values in B1:B500 with a small
routine between 'Loop' and 'End']
Thanks again
Jack
|