ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   search for date fields (https://www.excelbanter.com/excel-programming/297538-search-date-fields.html)

Danny[_7_]

search for date fields
 
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



Norman Jones

search for date fields
 
Hi Danny,

Perhaps something like:

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

--
Regards,
Norman

"Danny" wrote in message
...
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





Jake Marx[_3_]

search for date fields
 
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]


Danny wrote:
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



All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com