PDA

View Full Version : Searching a range



firefly2k8
07-19-2007, 02:39 AM
What is wrong with the following statement:

With Worksheets("BBData").Range(Cells(1, 1), Cells(1, 3))
Set c2 = .Find(DateOfCell, LookIn:=xlValues)

It throws up an "application or object defined error", I am trying to search through a range of cells determined in the code (so Cells(1,1) for example will be replaced by Cells(Row,Col)). Therefore I dont have the usual range("A3:A10") style of reference.

Thanks a lot in advance,
Martin

rory
07-19-2007, 03:07 AM
Hi Martin,
You haven't qualified the Cells property to refer to the worksheet so it defaults to the active worksheet. Try this:
With Worksheets("BBData")
With .Range(.Cells(1, 1), .Cells(1, 3))
Set c2 = .Find(DateOfCell, LookIn:=xlValues)


HTH
Rory