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

Asked By Felix_Jiang on 08-Dec-09 04:51 AM
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, _

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

End Sub

Sanjay replied to Felix_Jiang on 08-Dec-09 06:48 AM
I could not get much info, but please refer below link which may help you.





Mark "Yes", if the post if helpful.

Don Guillett replied to Felix_Jiang on 08-Dec-09 09:01 AM
?? Maybe something as simple as
msgbox cells(rows.count,"a").end(xlup).row

Don Guillett
Microsoft MVP Excel
SalesAid Software
Felix_Jiang replied to Sanjay on 08-Dec-09 10:10 AM
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.
Felix_Jiang replied to Felix_Jiang on 08-Dec-09 10:32 AM
I found the answer. The row count can be obtained by using