Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings! On an Excel Worksheet, A1 thru A5 contain:
6/1/2009 6/2/2009 6/3/2009 6/4/2009 6/12/2009 The following code runs perfectly. But when I uncomment the commented Selection.Find instruction, I get the following error message on execution: "Run-time error '91': Object variable or With block variable not set." and the following instruction (at line 22) is highlighted: Selection.Find(What:=DatePlusOne, LookIn:=xlFormulas _ , LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate The code is as follows: Option Explicit Sub FindCloseDateTST() Dim DateMinusOne As Date Dim DatePlusOne As Date DateMinusOne = "6/11/2009" DatePlusOne = "6/13/2009" Range("A1:A5").Select On Error GoTo CheckDateP1 ' Selection.Find(What:=DateMinusOne, LookIn:=xlFormulas _ ' , LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ ' MatchCase:=False, SearchFormat:=False).Activate '""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""" CheckDateP1: Range("A1:A5").Select On Error GoTo DateNotFound ' And here is Line 22: Selection.Find(What:=DatePlusOne, LookIn:=xlFormulas _ , LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate DateNotFound: MsgBox "All OK" End Sub -- Thank you very much for your help. Suggestions and work-arounds will be greatly appreciated. May you have a most blessed day! Sincerely, Michael Fitzpatrick |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find and Replace - delete the remainder of the text in the cell after my Find | Excel Programming | |||
Despite data existing in Excel 2002 spreadsheet Find doesn't find | Excel Discussion (Misc queries) | |||
Find method fails in hidden range | Excel Programming | |||
find and delete duplicate entries in two columns or find and prin. | Excel Programming | |||
Find instruction fails (from foreign sheet) | Excel Programming |