it was working, but not now, i couldn't figure out why,
i first have to pull out data from database by using querytable, refresh to worksheet, then count how many rows there r on the worksheet. but the number i got is 1 (there r 220 rows actually), why?
here's the code:
txt_sql = " SELECT ......"
Dim objQT As QueryTable
With Worksheets("Sheet1".QueryTables.Add(Connection:=X, _
Destination:=Range("A1", Sql:=txt_sql)
.Refresh
End With
Dim numofRows As Integer
numofRows = Sheets("Sheet1".UsedRange.Rows.Count
the code shouldnt' be wrong, and the rest of code shouldn't be either, is there any other reason may cause that problem? really appreciate if anybody could help me out.
i first have to pull out data from database by using querytable, refresh to worksheet, then count how many rows there r on the worksheet. but the number i got is 1 (there r 220 rows actually), why?
here's the code:
txt_sql = " SELECT ......"
Dim objQT As QueryTable
With Worksheets("Sheet1".QueryTables.Add(Connection:=X, _
Destination:=Range("A1", Sql:=txt_sql)
.Refresh
End With
Dim numofRows As Integer
numofRows = Sheets("Sheet1".UsedRange.Rows.Count
the code shouldnt' be wrong, and the rest of code shouldn't be either, is there any other reason may cause that problem? really appreciate if anybody could help me out.