E
Ed
I'm trying to determine if a given date exists within a list of dates. The
best my limited skills could produce was to use the Match function and check
for an error if the number wasn't in the list. Is there a better way? What
I have looks like this:
Sub Foo_TestMatch()
Dim wks As Worksheet
Dim rng As Range
Dim x As Long, y As Double
Set wks = ActiveSheet
Set rng = wks.Range("A1:A10")
x = 12
Err.Clear
On Error Resume Next
y = Application.WorksheetFunction.Match(x, rng, 0)
If Err.Number <> 0 Then MsgBox Err.Number
Err.Clear
On Error GoTo 0
End Sub
(To test this, I was just using numbers, so that's why nothing is a date.)
Ed
best my limited skills could produce was to use the Match function and check
for an error if the number wasn't in the list. Is there a better way? What
I have looks like this:
Sub Foo_TestMatch()
Dim wks As Worksheet
Dim rng As Range
Dim x As Long, y As Double
Set wks = ActiveSheet
Set rng = wks.Range("A1:A10")
x = 12
Err.Clear
On Error Resume Next
y = Application.WorksheetFunction.Match(x, rng, 0)
If Err.Number <> 0 Then MsgBox Err.Number
Err.Clear
On Error GoTo 0
End Sub
(To test this, I was just using numbers, so that's why nothing is a date.)
Ed