'i believe this is what you want.
'<cell value> is your "value in a cell"
do
if <cell value> = 0 then exit do
'<your macro loops here>
loop
it will go round and round until cell value = 0
also (more efficeintly) writen as:
do until <cell value> = 0
'<your macro loops here>
loop
Thank you BSOB.
I have tried creating a simple exercise to test the Loop. The loop should stop when the cell value reaches zero. When I run the Macro, the steps work, but the "do until" does not recognize the "zero" when it is actually computed. Therefore, I have to shut the operation down. Amazingly though, if I hardcode the zero, the loop stops as desired. The "test" code follows. Maybe someone will have an idea. Thanks.
-----------------------------------------------------------------------------
Sub Test_Loop()
'
' Test_Loop Macro
' Macro recorded 8/8/2006
'
' Go to ActiveCell.Value which should become zero:
Sheets("Control Sheet").Select
Range("F2").Select
' Do Until test:
Do Until ActiveCell.Value = 0
ActiveCell.Select
' Now to execute Macro:
Sheets("Piv-Summary").Select
ActiveSheet.PivotTables("PivotTable2").PivotSelect "", xlDataOnly
ActiveSheet.PivotTables("PivotTable2").RefreshTabl e
Sheets("Pivot-detail").Select
Rows("3:3").Select
Selection.Copy
Sheets("Assigned").Select
Rows("100:100").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
' Sort
Columns("A: D").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
' position cursor:
Range("c2").Select
' End of recorded Macro
Loop
End Sub