Results 1 to 5 of 5

Worksheetfunction.Match Issue

Threaded View

  1. #1
    Registered User
    Join Date
    10-29-2009
    Location
    NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Worksheetfunction.Match Issue

    Hi,

    I'm creating a UDF in which I use WorksheetFunction.Match.

    The Range I want to use is the first column of the user specified range.

    I achieve this as follows (I am only including the relevant part of the function for simplicity's sake):

    Function MyFunction(Lookup_Range As Range, Row_Header As Variant)
    
    Dim DRow, TRow, BRow, LCol, RCol As Integer
    Dim DSheet As String
    
    
    DSheet = Lookup_Range.Parent.Name 'Gets sheet Name
    
    TRow = Lookup_Range.Row 'Gets Top Row Number
    BRow = TRow + Lookup_Range.Rows.Count - 1 'Gets Bottom Row Number
    
    LCol = Lookup_Range.Column 'Gets Left Most Col Number
    RCol = LCol + Lookup_Range.Columns.Count - 1 'Gets Right Most Col Number
    
    DRow = WorksheetFunction.Match(Row_Header, Worksheets(DSheet).Range(Cells(TRow, LCol), Cells(BRow, LCol)), 0) 'For some reason this does not work????
    
    '...
    
    End Function
    Does anyone know why that line does not work? Note that when I removed the sheet name it worked fine (as long as the lookup range was in the same sheet as the cell with the function)
    Last edited by DonkeyOte; 11-01-2009 at 04:13 AM. Reason: tags added

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1