Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default unable to get match property of WorksheetFunction class

I have the following code :

If IsError(Application.WorksheetFunction.Match(cells( x, 1),
Worksheets("Sheet1").Range("A2:A15"), 0)) Then

do this

else

do that

The code works fine when there is a match ( for every cell in column A
of worksheet 2 it finds a match with the range A2:A15 in worksheet 1),
but I get the error 'unable to get match property of WorksheetFunction
class' when there is no match found i.e it gives a #N/A error. I dont
know what this error means. Any ideas ? Thanks

titus

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default unable to get match property of WorksheetFunction class


titus wrote:
I have the following code :

If IsError(Application.WorksheetFunction.Match(cells( x, 1),
Worksheets("Sheet1").Range("A2:A15"), 0)) Then

do this

else

do that

The code works fine when there is a match ( for every cell in column A
of worksheet 2 it finds a match with the range A2:A15 in worksheet 1),
but I get the error 'unable to get match property of WorksheetFunction
class' when there is no match found i.e it gives a #N/A error. I dont
know what this error means. Any ideas ? Thanks

titus


My bad. I searched this group and found the answer. The correct code
is:

If IsError(Application.Match(cells(x, 1),
Worksheets("Sheet1").Range("A2:A15"), 0))

Though I still dont get why application.worksheetfunction.match gave
me the error when it returned #N/A

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default unable to get match property of WorksheetFunction class

drop the .worksheetfunction stuff from your expression.

Application.match() will return an error if there is no match.

Application.worksheetfunction.match() will raise a trappable error that you have
to program against.

Application.match() is much simpler to use in my opinion, but you could do
something like:

dim res as long
res = 0
on error resume next 'avoid that blow up!
res = application.worksheetfunction.match(....)
if err.number < 0 then
'no match found
err.clear
'do what you want
else
'a match was found
end if
on error goto 0



titus wrote:

I have the following code :

If IsError(Application.WorksheetFunction.Match(cells( x, 1),
Worksheets("Sheet1").Range("A2:A15"), 0)) Then

do this

else

do that

The code works fine when there is a match ( for every cell in column A
of worksheet 2 it finds a match with the range A2:A15 in worksheet 1),
but I get the error 'unable to get match property of WorksheetFunction
class' when there is no match found i.e it gives a #N/A error. I dont
know what this error means. Any ideas ? Thanks

titus


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default unable to get match property of WorksheetFunction class


Dave Peterson wrote:
drop the .worksheetfunction stuff from your expression.

Application.match() will return an error if there is no match.

Application.worksheetfunction.match() will raise a trappable error that you have
to program against.

Application.match() is much simpler to use in my opinion, but you could do
something like:

dim res as long
res = 0
on error resume next 'avoid that blow up!
res = application.worksheetfunction.match(....)
if err.number < 0 then
'no match found
err.clear
'do what you want
else
'a match was found
end if
on error goto 0



titus wrote:

I have the following code :

If IsError(Application.WorksheetFunction.Match(cells( x, 1),
Worksheets("Sheet1").Range("A2:A15"), 0)) Then

do this

else

do that

The code works fine when there is a match ( for every cell in column A
of worksheet 2 it finds a match with the range A2:A15 in worksheet 1),
but I get the error 'unable to get match property of WorksheetFunction
class' when there is no match found i.e it gives a #N/A error. I dont
know what this error means. Any ideas ? Thanks

titus


--

Dave Peterson


Thanks Dave for the tip

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Unable to get the VLookup property of the WorksheetFunction class Ayo Excel Discussion (Misc queries) 4 August 6th 08 10:00 PM
Unable to get Match property of the WorksheetFunction class C++User Excel Programming 8 May 3rd 06 02:54 PM
Unable to get the Vlookup property of the WorksheetFunction class DoctorG Excel Programming 1 March 17th 06 06:49 PM
Unable to get the Text property of the WorksheetFunction class John[_86_] Excel Programming 5 November 25th 04 01:40 AM
Unable to get the Vlookup Property of the WorkSheetFunction Class monagan Excel Programming 2 August 3rd 04 09:32 PM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"