ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Worksheet function match - run time error (https://www.excelbanter.com/excel-worksheet-functions/149364-worksheet-function-match-run-time-error.html)

Sajit

Worksheet function match - run time error
 
Why does the statement give a run time error

If IsError(Application.WorksheetFunction.Match(chk_hd r1, 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

--
Sajit
Abu Dhabi

Toppers

Worksheet function match - run time error
 
try:

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

"Sajit" wrote:

Why does the statement give a run time error

If IsError(Application.WorksheetFunction.Match(chk_hd r1, 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

--
Sajit
Abu Dhabi


Sajit

Worksheet function match - run time error
 
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.
--
Sajit
Abu Dhabi


"Toppers" wrote:

try:

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

"Sajit" wrote:

Why does the statement give a run time error

If IsError(Application.WorksheetFunction.Match(chk_hd r1, 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

--
Sajit
Abu Dhabi


Wigi

Worksheet function match - run time error
 
Application.IsError

is short for

Application.WorksheetFunction.IsError

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


All times are GMT +1. The time now is 02:50 PM.

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