Worksheet function match - run time error

G

Guest

Why does the statement give a run time error

If IsError(Application.WorksheetFunction.Match(chk_hdr1, hdr_rng2, 0)) Then

where chk_hdr1 is a variable and hdr_rng2 is a column range name.

It gives the run time error 1004,

Unable to get the match property of the worksheetfunction class.

This happens only when the value of chk_hdr1 is not found in hdr_rng2
 
G

Guest

It seems IsError and IsNA are also worksheet functions.

I tried application.match but then after typing application. the match does
not show up. Which means it is a not a method.

But strange enough, what you said did work. Thank you.

Sub test()
Set myrange = Worksheets("Sheet1").Range("A1:CZ1")
If Application.IsError((Application.Match("stockcode", myrange, 0))) Then
msgbox("It worked")
End Sub

Is this not strange?

It sure drives one nuts.
 

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