Worksheetfunction MATCH

Y

Yves Janssens

Hi,

When I try the following I always get Run-time Error '1004': Unable to get
the Match property of the WorksheetFunction class

Workbooks.Open Filename:=filenaam, ReadOnly:=True
myVar = Application.WorksheetFunction.Match(9,
Worksheets(1).Range("A1:A10"), 0)
MsgBox myVar


What is the fault, I don't really see it.


Thanks a lot in advance,

Yves
 
T

Tom Ogilvy

Is there a 9 in Range A1:A10?

If not, then Match raises an error such as you describe.

Sub tester1()
On Error Resume Next
myvar = Empty
myvar = Application.WorksheetFunction.Match(9, _
Worksheets(1).Range("A1:A10"), 0)
On Error GoTo 0
If myvar <> Empty Then
MsgBox myvar
Else
MsgBox "Not found"
End If
End Sub


Might be an approach you can use.
 
Y

Yves Janssens

Tom,

Thanks a lot. There indeed is no value 9 in that range.
But, I never thaught it would generate this error.

Thanks a lot,

Yves
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top