Loop macro for a Newbie

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

I would like to be able to move to a specific page in my
spreadsheet when a condition is met. I need this to work
in one of my existing macros.

ie

When cell(15,8)=0
go to
Sheets("view").Select

otherwise
ActiveSheet.Calculate

Loop back.

How can one write a simple loop program?


Thanks and Happy new year.

Mike
 
try
Sub gothereif()
If Cells(15,8) =0 Then Application.Goto Sheets("view").Range("a1")
End Sub
 
sub WaitforAValue()
If Activesheet.Name = "Sheet1" then
do
if ActiveSheet.Cells(15,8) = 0 then
Worksheets("View").Activate
exit sub
Else
ActiveSheet.Calculate
end if
DoEvents
Loop while true
End If
End Sub

if cells(15,8) is a formula that calculate a floating point number, then it
may never equal zero. You would need a test like

if Abs(Activesheet.Cells(15,8).Value) < .0001 then

I assume there is something in your worksheet that would cause the value of
cells(15,8) to change on a calculate.
 
thanks. that works great
-----Original Message-----
sub WaitforAValue()
If Activesheet.Name = "Sheet1" then
do
if ActiveSheet.Cells(15,8) = 0 then
Worksheets("View").Activate
exit sub
Else
ActiveSheet.Calculate
end if
DoEvents
Loop while true
End If
End Sub

if cells(15,8) is a formula that calculate a floating point number, then it
may never equal zero. You would need a test like

if Abs(Activesheet.Cells(15,8).Value) < .0001 then

I assume there is something in your worksheet that would cause the value of
cells(15,8) to change on a calculate.

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy





.
 
Back
Top