View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Jon Peltier question: use of MATCH

Hi Byan,

"Bryan Kelly" wrote
[snip]
That is rather odd. The example came from selecting F1 with the "Match"
selected. The window is titled "Microsoft Excel Visual Basic." It seems
that one should assume that the example will work for visual basic. Oh
well


Responding just to this point, I highlighted Match on a worksheet and
presses F1. I was taken to the Excel Help page for Match which included the
following example (abbreviated by me):



In the preceding worksheet:




MATCH(39000,B2:B8,1) equals 3




MATCH(38000,B2:B8,0) equals 2




The first of these formulae corresponds exactly to that included in your
initial post.



In the VBE, if I highlight Match and press F1, I am conducted to the Visual
Basic Help page entitled: Using Microsoft Excel Worksheet Functions in
Visual Basic. This page includes the following pertinent excerpt:



If you use a worksheet function that requires a range reference as an
argument, you must specify a Range object. For example, you can use the
Match worksheet function to search a range of cells. In a worksheet cell,
you would enter a formula such as =MATCH(9,A1:A10,0). However, in a Visual
Basic procedure, you would specify a Range object to get the same result.



Sub FindFirst()
myVar = Application.WorksheetFunction _
.Match(9, Worksheets(1).Range("A1:A10"), 0)
MsgBox myVar
End Sub

End of excerpt




However, if on pressing F1 in Excel , the resultant window showed your
example and the window was entitled "Microsoft Excel Visual Basic." , then I
can understand your bemusement. I would find such an occurrence
extraordinary.




---
Regards,
Norman