I Need VBA Assistance Please

B

Brent E

Good afternoon,

I am using an Access module to control Excel and I need to know a VBA
command that will increment thru and look at all cells in Column B on an
Excel worksheet until
end of file or EOF. I tried DO UNTIL ... EOF, but didn't seem to work. Any
suggestions? Thanks.
 
K

Ken Snell [MVP]

This code assumes you're using early binding... if you're using late
binding, modify accordingly.

Dim xlRng As Excel.Range
For Each xlRng in Excel.Application.Workbooks(1).Worksheets(1).Range("B:B")
' search the value of the cell
If xlRng.Value = "My target value" Then
' code here
End If
Next xlRng
Set xlRng = Nothing
 
Top