I have a file which has rows extending to tens of thousands across 8 columns. One particular column contains the weekend date. I have to count the number of weekends present
You could connect to the appropriate worksheet using ADODB, and issue an SQL statement against the worksheet:
Dim datasourcePath As String
datasourcePath = "C:\path\to\excel\file.xlsx"
Dim connectionString As String
connectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=""" & datasourcePath & """;" & _
"Extended Properties=""Excel 12.0;HDR=No""
Dim sql As String
sql = "SELECT DISTINCT F1 FROM [Sheet1$]" 'F1 is an autogenerated field name
Dim rs As New ADODB.Recordset
rs.Open sql, connectionString
Do Until rs.EOF
Debug.Print rs("F1")
Loop