Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 44
Default Problems with Match function

Hi

I have a problem with the match function. This function requires three
parameters, but the following command fails:

Set wf = Application.WorksheetFunction
varMatch = wf.Match(strValue, ws.Range("B1:B1000"), 0)


but when I remove the third parameter, the function works?!? Is this a bug?

Tom



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problems with Match function

No.

0 as the third argument requires an exact match - apparently you are not
making a match, so an error is returned. When you remove the zero, match
finds the closes match, so you function works but you may get unexpected
results.

--
Regards,
Tom Ogilvy

"Tom" wrote in message
...
Hi

I have a problem with the match function. This function requires three
parameters, but the following command fails:

Set wf = Application.WorksheetFunction
varMatch = wf.Match(strValue, ws.Range("B1:B1000"), 0)


but when I remove the third parameter, the function works?!? Is this a

bug?

Tom





  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 44
Default Problems with Match function

Tom,

Thank you for your mail. I'm a little bit confused. Please find below my
example. The first match-function works, the 2nd fails, but I don't know
why... Maybe someone can help me...

Tom



Sub Test()
Dim a As Application
Dim wf As WorksheetFunction

Set a = Application
Set wf = Application.WorksheetFunction

With ActiveSheet

'this works
Debug.Print a.Match("Hello", .Range("A1:A1000"), 0)

'this fails
Debug.Print wf.Match("Hello", .Range("A1:A1000"), 0)
End With
End Sub




"Tom Ogilvy" schrieb im Newsbeitrag
...
No.

0 as the third argument requires an exact match - apparently you are not
making a match, so an error is returned. When you remove the zero, match
finds the closes match, so you function works but you may get unexpected
results.

--
Regards,
Tom Ogilvy

"Tom" wrote in message
...
Hi

I have a problem with the match function. This function requires three
parameters, but the following command fails:

Set wf = Application.WorksheetFunction
varMatch = wf.Match(strValue, ws.Range("B1:B1000"), 0)


but when I remove the third parameter, the function works?!? Is this a

bug?

Tom







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problems with Match function

If the second fails, then so does the first - you just are not checking for
the error. the second raises a 1004 error, the first returns a worksheet
style error.

Sub Test()
Dim a As Application
Dim wf As WorksheetFunction

Set a = Application
Set wf = Application.WorksheetFunction

With ActiveSheet

'this works
Debug.Print a.Match("Hello", .Range("A1:A1000"), 0)

'this fails
Debug.Print wf.Match("Hello", .Range("A1:A1000"), 0)
End With
End Sub

What do you get from your first debug.print

Error 2042

I would suspect.

? application.Match("XXX",Range("A1:A10"),0)
Error 2042

? cverr(xlErrNA)
Error 2042

? iserror(application.Match("XXX",Range("A1:A10"),0) )
True


--
Regards,
Tom Ogilvy






"Tom" wrote in message
...
Tom,

Thank you for your mail. I'm a little bit confused. Please find below my
example. The first match-function works, the 2nd fails, but I don't know
why... Maybe someone can help me...

Tom



Sub Test()
Dim a As Application
Dim wf As WorksheetFunction

Set a = Application
Set wf = Application.WorksheetFunction

With ActiveSheet

'this works
Debug.Print a.Match("Hello", .Range("A1:A1000"), 0)

'this fails
Debug.Print wf.Match("Hello", .Range("A1:A1000"), 0)
End With
End Sub




"Tom Ogilvy" schrieb im Newsbeitrag
...
No.

0 as the third argument requires an exact match - apparently you are not
making a match, so an error is returned. When you remove the zero,

match
finds the closes match, so you function works but you may get unexpected
results.

--
Regards,
Tom Ogilvy

"Tom" wrote in message
...
Hi

I have a problem with the match function. This function requires three
parameters, but the following command fails:

Set wf = Application.WorksheetFunction
varMatch = wf.Match(strValue, ws.Range("B1:B1000"), 0)


but when I remove the third parameter, the function works?!? Is this a

bug?

Tom









  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 44
Default Problems with Match function

Thank you, now it's clear...

Tom



"Tom Ogilvy" schrieb im Newsbeitrag
...
If the second fails, then so does the first - you just are not checking

for
the error. the second raises a 1004 error, the first returns a worksheet
style error.

Sub Test()
Dim a As Application
Dim wf As WorksheetFunction

Set a = Application
Set wf = Application.WorksheetFunction

With ActiveSheet

'this works
Debug.Print a.Match("Hello", .Range("A1:A1000"), 0)

'this fails
Debug.Print wf.Match("Hello", .Range("A1:A1000"), 0)
End With
End Sub

What do you get from your first debug.print

Error 2042

I would suspect.

? application.Match("XXX",Range("A1:A10"),0)
Error 2042

? cverr(xlErrNA)
Error 2042

? iserror(application.Match("XXX",Range("A1:A10"),0) )
True


--
Regards,
Tom Ogilvy






"Tom" wrote in message
...
Tom,

Thank you for your mail. I'm a little bit confused. Please find below my
example. The first match-function works, the 2nd fails, but I don't know
why... Maybe someone can help me...

Tom



Sub Test()
Dim a As Application
Dim wf As WorksheetFunction

Set a = Application
Set wf = Application.WorksheetFunction

With ActiveSheet

'this works
Debug.Print a.Match("Hello", .Range("A1:A1000"), 0)

'this fails
Debug.Print wf.Match("Hello", .Range("A1:A1000"), 0)
End With
End Sub




"Tom Ogilvy" schrieb im Newsbeitrag
...
No.

0 as the third argument requires an exact match - apparently you are

not
making a match, so an error is returned. When you remove the zero,

match
finds the closes match, so you function works but you may get

unexpected
results.

--
Regards,
Tom Ogilvy

"Tom" wrote in message
...
Hi

I have a problem with the match function. This function requires

three
parameters, but the following command fails:

Set wf = Application.WorksheetFunction
varMatch = wf.Match(strValue, ws.Range("B1:B1000"), 0)


but when I remove the third parameter, the function works?!? Is this

a
bug?

Tom











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
IF , MATCH problems with formula treeroot Excel Worksheet Functions 1 September 29th 08 06:14 PM
IF , match formula problems treeroot Excel Worksheet Functions 1 September 25th 08 06:33 AM
LOOKUP MATCH problems Jason Excel Worksheet Functions 6 June 15th 07 09:53 AM
Match and Lookup problems Titanus Excel Worksheet Functions 4 April 6th 06 08:46 PM
Index match problems Don O Excel Worksheet Functions 2 November 25th 04 05:04 AM


All times are GMT +1. The time now is 06:38 AM.

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

About Us

"It's about Microsoft Excel"