おそらくやり過ぎですが、ワークシートへの ADODB 接続を作成できます。
Dim conn As New Connection
With conn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=""" & ActiveWorkbook.FullName & """;" & _
"Extended Properties=""Excel 12.0;HDR=No;"""
'If you're running a version of Excel earlier than 2007, the connection string should look like this:
'.ConnectionString = "Data Source=""" & ActiveWorkbook.FullName & """;" & _
' "Extended Properties=""Excel 8.0;HDR=No;"""
.Open
End With
次に、ワークシートに対して SQL ステートメントを発行できます。
Dim rs As Recordset
Set rs = conn.Execute( _
"SELECT F2 AS LastName, F1 AS FirstName, Count(*) AS C " & _
"FROM [Sheet1$A$2:$B$1800] " & _
"GROUP BY F2, F1" _
)