Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Searching for a Date

-Hello Everyone

I have a problem searching for a date. It works when I record it but not
when I run the code.

Sub FindDate

Cells.Find(What:="14/12/2005", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

End Sub

Running the macro above returns 'Object variable or With block variable not
set'
But if I end the code and do Shift+F4 to 'find again' Excel goes straight to
the cell?

Thanks for reading this far, and in advance for any help

Matt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Searching for a Date

Sub FindDate()

Cells.Find(What:=CDate("14/12/2005"), _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate

End Sub


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Matt" wrote in message
...
-Hello Everyone

I have a problem searching for a date. It works when I record it but not
when I run the code.

Sub FindDate

Cells.Find(What:="14/12/2005", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns,

SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

End Sub

Running the macro above returns 'Object variable or With block variable

not
set'
But if I end the code and do Shift+F4 to 'find again' Excel goes straight

to
the cell?

Thanks for reading this far, and in advance for any help

Matt




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Searching for a Date

That's done the trick

Thanks Bob

Matt


"Bob Phillips" wrote:

Sub FindDate()

Cells.Find(What:=CDate("14/12/2005"), _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate

End Sub


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Matt" wrote in message
...
-Hello Everyone

I have a problem searching for a date. It works when I record it but not
when I run the code.

Sub FindDate

Cells.Find(What:="14/12/2005", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns,

SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

End Sub

Running the macro above returns 'Object variable or With block variable

not
set'
But if I end the code and do Shift+F4 to 'find again' Excel goes straight

to
the cell?

Thanks for reading this far, and in advance for any help

Matt





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching a date Neil Meehan Excel Discussion (Misc queries) 1 April 30th 06 03:12 PM
Date Range Searching Eric[_25_] Excel Programming 1 September 11th 04 01:47 PM
searching a date range. chrisdarl[_16_] Excel Programming 2 May 18th 04 12:34 PM
Searching by date Bob Phillips[_6_] Excel Programming 0 March 3rd 04 01:57 PM
searching date Irunalotta Excel Programming 1 December 2nd 03 06:37 PM


All times are GMT +1. The time now is 12:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"