search for date fields

D

Danny

Hi,

I've been trying for a while, but I can't figure it out - how do you
search for a date cell from an array of dates - I can only search for string
values, although all the cells contain dates.
Did anyone have to do this before (no luck with search function) - any
hints?

Best regards
 
N

Norman Jones

Hi Danny,

Perhaps something like:

For Each cell In rng
If IsDate(cell) Then
'do something
End If
Next cell
 
J

Jake Marx

Hi Danny,

This code works for me. Have you tried the Find method?

Sub test()
Dim dt As Date
Dim rng As Range

dt = DateSerial(2003, 12, 2)

Set rng = Sheet1.UsedRange.Find(what:=dt)
If Not rng Is Nothing Then MsgBox rng.Address
Set rng = Nothing
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Top