citizenzen
Programmer
is it really possible to include a second query within my module that will highlight found records based on the query?
i have 2 queries. the first one runs successfully. however, i want to include a second query that is also pulled from the database. with the second query, i am searching through the worksheet, and based on the results of the second query, highlight only those cells.
if someone can point me to a tutorial that shows this, i would also appreciate that as well. Or is it something simple within my code?
i am getting an 'Application- defined or object defined error' on the following line
This is the sub i am working with:
thanks in advance.
i have 2 queries. the first one runs successfully. however, i want to include a second query that is also pulled from the database. with the second query, i am searching through the worksheet, and based on the results of the second query, highlight only those cells.
if someone can point me to a tutorial that shows this, i would also appreciate that as well. Or is it something simple within my code?
i am getting an 'Application- defined or object defined error' on the following line
Code:
ws_dest.Cells.Value(rng).Interior.Color = RGB(255, 255, 153)
This is the sub i am working with:
Code:
While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
row = 2
ws_dest.Range("A:C").EntireColumn.AutoFit
Set rng = ws_dest.Cells(row, i + 1)
ws_dest.Range("A2:C484").CopyFromRecordset rs
row = row + 2
Next i
'2) Search through above results and highlight cells based on prs recordset
For i = 0 To prs.Fields.Count - 1
Do Until prs.EOF
If (InStr(rng, prs.Fields(i))) Then
ws_dest.Cells.Value(rng).Interior.Color = RGB(255, 255, 153) 'error is here
End If
Loop
Next i
rs.MoveNext
Wend
End Sub
thanks in advance.