Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Do without loop when using query

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

I've tried with a for/next statement with the same issue.

Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Do without loop when using query

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

wrote in message
ups.com...
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
-----------------------

I've tried with a for/next statement with the same issue.

Any ideas?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
(Complex) Loop within loop to create worksheets klysell Excel Programming 1 March 20th 07 12:03 AM
LOOP query Pedro AM Excel Discussion (Misc queries) 2 February 14th 07 05:32 AM
Looping SQL query w/changing parameters in each loop not working Laurin[_3_] Excel Programming 7 December 9th 05 03:35 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"