I have found some online code that I am trying to incorporate into my procedure, however, am having some difficulties.
The code is as follows
Sub Test()
Const var As String = "BM01"
Dim projects As Variant
Dim x As Long
projects = Array("BM01", "BM02", "BM03", "BM04")
On Error Resume Next
x = WorksheetFunction.Match(var, projects, False)
If Err = 0 Then
' **** do something ****
MsgBox "Found"
Else
' **** clear error ****
Err.Clear
MsgBox "Not Found"
End If
On Error GoTo 0
End Sub
Rather than having projects defined as a hardcoded array, I was hoping to have this pointing to a range.
My range is cells "B12:B16"
When I set projects to equal this range I always get a not found message.
Dim projects as Variant
projects = Range("B12:B16")
Is anyone able to help?
Thanks
McCrimmon
Bookmarks