How to do the coding on UNTIL loop?

G

Guest

Does anyone have any suggestions on how to do the coding on Macro?

[Loop for Until]
[Perform following code]

Workbooks.Open Filename:="C:\1.xls", UpdateLinks:=3
Workbooks("1.xls").Close savechanges:=True

Until 'C:\[Data.xls]Sheet1'!$A$1 >0
[Exit Until Loop]

Thank for any suggestions
Eric
 
G

Guest

Eric,

Generally the format for a do loop is as follows

Sub sonic()
Do
Cells(1, 1).Value = Int((12 * Rnd) + 1)
Loop While Cells(1, 1).Value <> 10
End Sub

This simple loop writes a random number to A1 every loop and the loop exits
when A1 = 10. All pretty pointless but a demonstration of how it works.

Mike
 
G

Guest

Thank everyone for suggestions

My requirement is to open the file at least once, if the value from
'C:\[Data.xls]Sheet1'!$A$1 >0, then re-open the file again, there is the
reason for this loop.
If I apply your code to my case, it shows as below,
Am I right?

Sub Eric()
Do
Workbooks.Open Filename:="C:\1.xls", UpdateLinks:=3
Workbooks("1.xls").Close savechanges:=True
Loop While 'C:\[Data.xls]Sheet1'!$A$1 >0
End Sub


Mike H said:
Eric,

Generally the format for a do loop is as follows

Sub sonic()
Do
Cells(1, 1).Value = Int((12 * Rnd) + 1)
Loop While Cells(1, 1).Value <> 10
End Sub

This simple loop writes a random number to A1 every loop and the loop exits
when A1 = 10. All pretty pointless but a demonstration of how it works.

Mike
Eric said:
Does anyone have any suggestions on how to do the coding on Macro?

[Loop for Until]
[Perform following code]

Workbooks.Open Filename:="C:\1.xls", UpdateLinks:=3
Workbooks("1.xls").Close savechanges:=True

Until 'C:\[Data.xls]Sheet1'!$A$1 >0
[Exit Until Loop]

Thank for any suggestions
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top