title: =MATCH() equivalent for multidimensional ranges
body: <p>I have an excel sheet, where cells A1-C20=<code>=INT(RAND()*10)</code>.  This is my data range.  Cell E1=1, E2=2, E3=3, etc.  These are the values I am trying to find.  I set cell F1=<code>=MATCH(E1,A:C,0)</code>, F2=<code>=MATCH(E1,A:C,0)</code>, etc.</p>
  
  <p>However, all the <code>MATCH</code> functions return <code>#N/A</code>, because the input range is multi-dimensional.  How can I test whether a given value (1, 2, 3, 4, etc.) exists in a multidimensional range (A1-C20)?</p>
  
  <p>/edit:  <a href="http://www.ozgrid.com/VBA/ultimate-excel-lookup-function.htm" rel="nofollow">This function</a> works, but is more than I need.  Is there any way to make it return just TRUE or FALSE, depending on if the lookup value is in the range?</p>
  
  <pre><code>Function OzgridLookup(Find_Val As Variant, Occurrence As Long, Table_Range As Range, _
   Offset_Cols As Long, Optional Column_Lookin As Long, Optional Row_Offset As Long) As Variant
  
  Dim lLoop As Long
  Dim FoundCell As Range
  
      If Column_Lookin = 0 Then 'No column # specified
          With Table_Range
              'Top left cell has Find_Val &amp; Occurrence is 1
              If Table_Range.Cells(1, 1) = Find_Val And Occurrence = 1 Then
                OzgridLookup = .Cells(1, 1)(1, Offset_Cols + 1)
                Exit Function 'All done :)
              Else 'No column # specified so search all for _
                      nth Occurrence reading left to right
               Set FoundCell = .Cells(1, 1) 'Set cell variable for Find start
                  For lLoop = 1 To Occurrence 'Loop as many times as Occurrences _
                   and each time Set "FoundCell" to start next Find from
                    Set FoundCell = _
                          Table_Range.Find(What:=Find_Val, After:=FoundCell, _
                              LookIn:=xlValues, LookAt:=xlWhole, _
                              SearchOrder:=xlRows, SearchDirection:=xlNext)
                  Next lLoop
              End If
          End With
      Else 'column # specified
        With Table_Range.Columns(Column_Lookin) 'Work with column # specified
          Set FoundCell = .Cells(1, 1) 'Set cell variable for Find start
              For lLoop = 1 To Occurrence 'Loop as many times as Occurrences _
                   and each time Set "FoundCell" to start next Find from
                    Set FoundCell = _
                          Table_Range.Find(What:=Find_Val, After:=FoundCell, _
                              LookIn:=xlValues, LookAt:=xlWhole, _
                              SearchOrder:=xlRows, SearchDirection:=xlNext)
              Next lLoop
        End With
      End If
  
      OzgridLookup = FoundCell.Offset(Row_Offset, Offset_Cols)
  
  End Function
  </code></pre>