I have an array containing values in Sheet1.Range(A1:A10).
After I open my recordset I'd like to filter the data based on values in my array. Is this possible at all?
Thanks
I have an array containing values in Sheet1.Range(A1:A10).
After I open my recordset I'd like to filter the data based on values in my array. Is this possible at all?
Thanks
This is too long for a comment, so here are a couple of functions I use (this assumes strings as the criteria):
Function GetStringInList(rngCriteria As Range) As String
Dim rngCell As Range
Dim strTemp As String
For Each rngCell In rngCriteria.Cells
If Len(rngCell.Value) > 0 Then strTemp = strTemp & ",'" & DoubleQuotes(rngCell.Value) & "'"
Next rngCell
' now strip off leading comma
GetStringInList = Mid$(strTemp, 2)
End Function
Function DoubleQuotes(strIn As String) As String
DoubleQuotes = Replace(strIn, "'", "''")
End Function
so when building the SQL you could use something like:
strSQL = strSQL & " WHERE [FieldName] In " & GetStringInList(Range("A1:A10"))