Excel 2003 - VBA - More querys

C

Craig Brandt

I cannot find a solution here and I cannot be the first person that has run
a query, then needed to know how may elements are in the result.

I do a query and count the elements. The count is wrong since the data is
not there yet.

I tried to add a timer delay after the query but before the count. The data
isn't presented until after the timer expires (no matter how long the timer)

I tried to break the task into two buttons on the userform. One to do the
querys and the second to proceed. The count is obviously in the proceed
button. I never get the data.

Obviously, I must be during the query wrong, but if I breakpoint the "sub
end", right after the query, it works. I've appended the Query code.

Can some help here.

Craig
....
....
....

Sheets("Querys").Select
For Counter = 1 To NumSym
SymbolDPtr.Offset(-1, 0) = SymbolSPtr
' Build the URL for this query
URL = "http://ichart.finance.yahoo.com/table.csv?s=" & SymbolSPtr &
"&d=" & em & "&e=" & ed & "&f=" & ey & "&g=d&a=" & sm & "&b=" & sd & "&c=" &
sy & "&ignore=.csv"
Set urlRequest = ActiveSheet.QueryTables.Add(Connection:="URL;" +
URL, Destination:=SymbolDPtr)
With urlRequest
.WebSingleBlockTextImport = True
.WebFormatting = xlNone
.RefreshStyle = xlOverwriteCells
.Refresh
End With
' Increment Points to next symbol
Set SymbolSPtr = SymbolSPtr.Offset(1, 0)
Set SymbolDPtr = SymbolDPtr.Offset(0, 1)
' Loop back
Next Counter
 

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