Do without loop when using query

N

no.reply7

I'm stuck:

the following sample code works

----------------------
i = 0
Do Until i = 5
ActiveCell.Offset(0, i) = i
i = i + 1
Loop
-------------------------

Now, the following doesn't and returns a "Do without Loop" error
message

-----------------------
i = 0
Do Until i = 5
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;http://table.finance.yahoo.com/table.csv?s=" & ticker &
i & "&g=d&ignore=.csv", _
Destination:=ActiveCell)
.TextFileCommaDelimiter = True
.TextFileColumnDataTypes = Array(1, 9, 9, 9, 9, 9, 1)
.Refresh BackgroundQuery:=False
ActiveCell.Offset(0, 2).Select
Loop
 
P

PCLIVE

You're missing and "End With".

I = 0
Do Until I = 5
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;http://table.finance.yahoo.com/table.csv?s=" & ticker & I
& "&g=d&ignore=.csv", _
Destination:=ActiveCell)
.TextFileCommaDelimiter = True
.TextFileColumnDataTypes = Array(1, 9, 9, 9, 9, 9, 1)
.Refresh BackgroundQuery:=False
End With
ActiveCell.Offset(0, 2).Select
Loop

HTH,
Paul
 

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