Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error searching for date using cells.find function

Status
Not open for further replies.

krakyn

Technical User
Oct 14, 2003
1
GB
Hi,

Please help,
I am trying to search for a date within a spreadsheet using the following VBA code:

dim found as range

set found = cells.find(What:="24/03/1983"
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)

And it doesnt find the string since found contains
nothing![surprise] how can this be since in my code the
date is surrounded by quotes making it a string

Also how can i change the code to allow for a search in
either direction using numbers or text as arguments.

Thanx in adv.
Krakyn [afro]
 
This is what I had and it worked fine:

Code:
Dim found As Range
Set found = Cells.Find(What:="26/10/2003", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
        
MsgBox found
found.Activate

When I had .Activate at the end of the "Set found=..." however, found was null. It also didn't matter if the cells were formatted as a date or text. My date was custom (d/m/yyyy).

Not sure what you mean on the 2nd question. Sorry.

Hope that helps.



DreamerZ
simplesoftware@prodigy.net
[ignore][/ignore]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top