View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Vera Vera is offline
external usenet poster
 
Posts: 1
Default Run-time error '91' on Cells.Find()

Hi,

I recorded a macro to find a date in a worksheet. The
generated code looks like this:

Range("A2").Select
Application.FindFormat.Clear
Application.FindFormat.NumberFormat = "dd/mm/yyyy"
Application.FindFormat.....
....
Cells.Find(What:="20-01-2004", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=True).Activate

However, when I try to run this macro, I get an error
message: Run-time error '91': Object variable or With
block variable not set. When I click debug, the error
appears to be caused by the Cells.Find() statement.

My intension is to create a ThisWorkbook.Open method that
finds the current date in the worksheet.

What can I do to make this macro work?
Any help will be greatly appreciated.