Forum Discussion
cool2021
Feb 19, 2023Iron Contributor
Count number of records - QueryTable.CommandText property (Excel) - VBA and Power Query
Why will the following SQL statement not work re: count number of records and group by ProductName:
Set qtQtrResults = _ Workbooks(1).Worksheets(1).QueryTables(1)
With qtQtrResults
.CommandType = xlCmdSQL
.CommandText = "SELECT ProductName, Count(*) FROM Products GROUP BY ProductName"
.Refresh
End With
No RepliesBe the first to reply