Hi all!!
this is the code i use:
Sub WebQueries()
Dim Wq As Range
Dim Wqs As Worksheet
Dim i, j As Integer
Set Wq = ThisWorkbook.Sheets(3).Range("A1")
Set Wqs = ThisWorkbook.Sheets(3)
On Error Resume Next
For i = 0 To 13
Wqs.Range(Cells(3 + 20 * i, 9), Cells(1 + 20 * (i + 1), 20)).Clear
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.nbrb.by/statistics/PrStavkiN/?date=" & Wq(2 + 20 * i, 9), Destination:=Cells(4 + 20 * i, 9))
.Name = "?date=" & Left(Wq(2 + 20 * i, 9), 5)
.WebTables = "15"
.Refresh
End With
Next i
On Error GoTo 0
Set Wq = Nothing
Set Wqs = Nothing
End Sub
as the result i get 14 tables from web when what table it will be depends on dates in cells, say, Wq(2 + 20 * i, 9)
The problem is that when excel start count number of requests by this data table - i get no data. it looks like follow:?date=15.10_11, where 15.10 is the table name and 11 is number of requests. This think wont work but if i put only ?date=15.10 in cell and refresh then it works great. So 2 questions.
1 - how to prevent excel from counting and do query always like 1st time
2. My on error resume next doesn't work if i try request data that doesn't exist and i get nasty messages. How i really tell exxcel to ignore these errors??
Thanks in advance!
Bookmarks