Link to home
Start Free TrialLog in
Avatar of joyacv2
joyacv2Flag for Puerto Rico

asked on

timed loop in excel

Hi,

I have the following code:
private sub Workbook_Open()

do while f <> 100

application.ontime now + timeserial(0,0,5) , "test"

loop

end sub

sub test()
x = x +1
sheet1.cells(x,1).value = x + 2

end sub

Open in new window


I want to run this code in the background while i do other things in my workbook, but this code freezes all the worksheets and the workbook, what i can do? How i can run codes in the background while modifying part of the worksheet?
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

for sure

What is f ?
where do you put your code test in a module or where ?
x in test is declared in a module as the way you posted the code each time test starts x = 0 is this what you want ???

and most of all your missing doevents reason why the whole thing freezes but still ur code does not make sense as f is not initialized somewhere else.

Best is to say what you want then will put the code for you.
gowflow
Avatar of joyacv2

ASKER

f is a variable that nevers reach 100, so the loop is forever,
test is in a module
x starts at 0

What and where is necessary the doevents?
Avatar of joyacv2

ASKER

the code will modify part of the sheet while the user is changing other parts of the sheet
ASKER CERTIFIED SOLUTION
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joyacv2

ASKER

works excellent, and give me a lots of ideas!!!, Thanks!!!
your welcome my pleasure glad I could help.
gowflow