View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Application.Match

Few things here.

"SIGE" wrote in message
om...
Why does Application.Match or Application.Worksheetfunction.Match
not work with integers as look-up value?


Match does work with an integer value, but you have to get the syntax
correct.

When comparing with integers, why do you use a string?
The range is not the same in VBA as in Excel, you have to adapt.

I read there is a difference between both functions ...but coul'n't
get in what way there is a difference...


The difference lies in its error handling. In XL97, there was a problem with
the WorksheetFunction form of Match that did not manifest with
Application.Match. Myrna Larson reporst that she has experienced that
problem in later versions. For that reason, it is generally agrreed to be
safe rather than sorry and use Application.Match.

'fill row1 wihth the numbers 1,2,3,4,5,... and I get a type mismatch,
error 13 on running underneath sub.

Sub test()
Dim sige As Integer
sige = Application.WorksheetFunction.Match("1", "Sheet1!$A$1:$K$1", 0)
MsgBox sige
End Sub


With correct syntax, and some error handling, it should work okay

Sub test()
Dim sige
On Error Resume Next
sige = Application.Match(99, Range("Sheet3!$A$1:$K$1"), 0)
If Not IsError(sige) Then
MsgBox sige
End If
On Error GoTo 0
End Sub