How to obtain the row count of a QueryTable from a Web query

  • Thread starter Thread starter Felix_Jiang
  • Start date Start date
F

Felix_Jiang

I use a Web query to obtain a table on a Web page. How can I know the number
of rows in the result QueryTable?

The current code I use is as follows:

Sub Test()
Dim MyStr As String
MyStr = "URL;http://mySite/currentuser"
With ActiveSheet.QueryTables.Add(Connection:=MyStr, _
Destination:=Range("a10"))

.RowNumbers = True
.WebSelectionType = xlSpecifiedTables
.WebTables = "11"
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With


End Sub
 
Thank you Sanjay. I want to know the row count in the QueryTable returned by
ActiveSheet.QueryTables.Add. Then after I put the QueryTable into Excel, I
can calculate the last affected row in Excel. This will help me to know where
to start adding new QueryTable.
 
I found the answer. The row count can be obtained by using
QueryTable.ResultRange.Rows.Count
 
Back
Top