I have been using ACE.OLEDB and SQL to query for data in my Excel worksheets. Then the Access DB 255 column limit bite me!
How do others query for data without using SQL?
I have tried such things as ranges and dictionaries:
Public Sub DynamicQuery()
Dim hRng As Range 'Header Range
Dim hDict As Object, hItem As Variant, i As Long
Set hDict = CreateObject("Scripting.Dictionary")
Set hRng = Cells(1, Cells.SpecialCells(xlCellTypeLastCell).Column)
Debug.Print hRng.Find("c").Column
For i = 1 To Cells.SpecialCells(xlCellTypeLastCell).Column
If Not hDict.exists(Cells(1, i).Value) Then
hDict.Add Cells(1, i).Value, i
End If
Next i
Debug.Print hDict("c")
For i = 2 To Cells.SpecialCells(xlCellTypeLastCell).Row
Debug.Print Cells(i, hRng.Find("c").Column).Value
Debug.Print Cells(i, hDict("c")).Value
Next i
End Sub
What are some other ideas / better ways to query for data?
{the sample worksheet for that code above simply has a column header named "c" and a few rows of data}
V/R
Rich
Bookmarks