Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 9 in "How to find a date in a range with VBA ?"
Dim lngRow As Long
Dim dteInput As Date 'Range has several dates formatted as "ddd, dd/mm/aa" Range("G3:G10").Select 'dteInput is being copied from a cell that has "23/11/2004" as a date value (format cell = date) 'I use Windows XP, Excel XP with Spanish settings! With Selection 'I get a runtime error 9 here lngRow = Cells.Find(What:=dteInput, After:=ActiveCell, LookIn:=xlFormula, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row MsgBox "lngRowDteImport = " & lngRowDteImport, vbInformation End With If lngRowDteImport 0 Then 'Import Fecha already exists in Range G3:G10! MsgBox "Date " & CStr(dteImport) & exists", vbInformation, "Terminated" Exit Sub Any idea why this gives an error? TIA Martin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Runtime error 9 in "How to find a date in a range with VBA ?"
One possible reason is if the sheet is protected or hidden then you will have
a problem. "Martin Los" wrote: Dim lngRow As Long Dim dteInput As Date 'Range has several dates formatted as "ddd, dd/mm/aa" Range("G3:G10").Select 'dteInput is being copied from a cell that has "23/11/2004" as a date value (format cell = date) 'I use Windows XP, Excel XP with Spanish settings! With Selection 'I get a runtime error 9 here lngRow = Cells.Find(What:=dteInput, After:=ActiveCell, LookIn:=xlFormula, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row MsgBox "lngRowDteImport = " & lngRowDteImport, vbInformation End With If lngRowDteImport 0 Then 'Import Fecha already exists in Range G3:G10! MsgBox "Date " & CStr(dteImport) & exists", vbInformation, "Terminated" Exit Sub Any idea why this gives an error? TIA Martin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"Microsoft Visual Basic runtime error '424' object required". | Excel Worksheet Functions | |||
How do I correct Runtime error "53" in excel 2003 | Excel Discussion (Misc queries) | |||
Excel:Runtime Error 7 "Not enough Memory" with CreateObject (SAP.B | Excel Programming | |||
Runtime Error "1004" Select Method of Range Class Failed | Excel Programming |