ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   date function (https://www.excelbanter.com/excel-discussion-misc-queries/78765-date-function.html)

[email protected]

date function
 
I am trying to make a function that will search a range of dates (the
first argument) and if it matches the date in the second argument will
return true. I keep getting #VALUE errors with the second argument.
I'm a bit stuck. I'd appreciate any help I can get.


Function MatchDate(TPRrange As range, TPRDate As range) As Boolean
Application.Volatile (True)
Dim c
For Each c In ActiveWorkbook.range(TPRrange)
If c.Value = range(TPRDate) Then MatchDate = True
Exit For
Next
MatchDate = False
End Function


Function MatchDate2(TPRrange As range, TPRDate As Date) As Boolean
Application.Volatile (True)
Dim Index As Variant

' Find a match for the serial value of the date in the range A1:A10
' on Sheet1.
Index = Application.Match(CLng(TPRDate), range(TPRrange), 0)

' Display the results.
If IsError(Index) Then
MatchDate2 = True
Else
MatchDate2 = False
End If
End Function


Thanks,
G



All times are GMT +1. The time now is 08:32 AM.

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