View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Fred Smith Fred Smith is offline
external usenet poster
 
Posts: 623
Default Finding a date rather than text

Thanks, Tom. Just what I needed.

--
Regards,
Fred


"Tom Ogilvy" wrote in message
...
Dim rng as Range, FoundCell as Range
Dim res as Variant
set rng = Columns(1).Cells
res = Application.Match(clng(DateValue("1/1/2003")),rng,0)
if not iserror(res) then
set FoundCell = rng(res)
Else
msgbox "Not found"
exit sub
end if

msgbox "Found at " & foundcell.Address

--
Regards,
Tom Ogilvy


"Fred Smith" wrote in message
...
I have a column of dates. I want to find the cell which contains the date
1/1/2003. The code I tried is:

Set Foundcell = Range("A:A").Find(What:="1/1/2003")

Unfortunately, because the dates are in reverse chronological order, the Find
stops at 11/1/2003.

What code do I need to get Excel to check for a date, rather than a string? I
tried What:=#1/1/2003# but that didn't help.

--
Thanks,
Fred