View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Do until loop with use of another macro in loop

I don't know in your case how A1 gets to ten I assume you have a worksheet
formula to achieve this but the sub 'doforawhile' below will continually call
the second sub 'randomgenerato' until cell A1 on sheet1 = 10

Sub doforawhile()
Do
randomgenerator
Loop Until Worksheets("Sheet1").Cells(1, 1).Value = 10
End Sub

Sub randomgenerator()
myvalue = Int((10 * Rnd) + 1)
Worksheets("Sheet1").Cells(1, 1).Value = myvalue
End Sub

"The Excelerator" wrote:

I am searching for some simple code to run a macro for a Do .. While loop,
where it continues to activate another macro event until a certain cell
reaches a predetermined count value.
For example ... lets say we run a rand number generator that copies the
generated diigt to a list (using an absolute copy paste to another location)
- under a separate macro (macro "RandomNumber") - and a cell (A1) counts the
number of 7's that appear. When it reaches the count of TEN appearances, then
the loop ceases and thus the macro RandomNumber" also ceases, until next
activated.