ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop macro for a Newbie (https://www.excelbanter.com/excel-programming/286601-loop-macro-newbie.html)

mike

Loop macro for a Newbie
 
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


Don Guillett[_4_]

Loop macro for a Newbie
 
try
Sub gothereif()
If Cells(15,8) =0 Then Application.Goto Sheets("view").Range("a1")
End Sub
--
Don Guillett
SalesAid Software

"mike" wrote in message
...
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




Tom Ogilvy

Loop macro for a Newbie
 
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


"mike" wrote in message
...
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




No Name

Loop macro for a Newbie
 
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


"mike" wrote in

message
...
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



.



All times are GMT +1. The time now is 02:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com