Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding a date rather than text
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding a date rather than text
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding a Date 90 days previous to present date | Excel Worksheet Functions | |||
Finding text in a cell and returning a value based on that text | Excel Discussion (Misc queries) | |||
finding a date/time in a list that is closest to an existing date/ | Excel Discussion (Misc queries) | |||
Finding the Monday date based on a different date in same week | Excel Worksheet Functions | |||
Finding Specific Text in a Text String | Excel Worksheet Functions |