Results 1 to 7 of 7

MATCH function with a variable as lookup_value?

Threaded View

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    4

    MATCH function with a variable as lookup_value?

    Hi,

    I want to use the MATCH(lookup_value, lookup_array, [match_type]) function in VBA.
    I need the lookup_value to be a variable (dim as long), but I can´t get this to work, see below. It works fine when I use a number as lookup_value, but not a variable.

    Sub A()
        Dim TESTO As Long
        Dim Vendor As Long
        Dim ComplaintType As String
    
    For X = 7 To 20
    ComplaintType = ThisWorkbook.Sheets("rådatacalle").Cells(X, 6).Value
    
    Select Case ComplaintType
    
    
    Case Is = "Other"
    Vendor = ThisWorkbook.Sheets("rådatacalle").Cells(X, 2).Value
    'Vendor this time gets the value 8077, but next round in the loop Vendor will have a different value
    
         TESTO = Application.WorksheetFunction.Match("8077", Sheets("Sammanställning").Range("a1:a90"), 0)   'DOES WORK
         TESTO = Application.WorksheetFunction.Match(8077, Sheets("Sammanställning").Range("a1:a90"), 0)     'DOES NOT WORK
         TESTO = Application.WorksheetFunction.Match("Vendor", Sheets("Sammanställning").Range("a1:a90"), 0) 'DOES NOT WORK. Vendor is a variable with value 8077.
         TESTO = Application.WorksheetFunction.Match(Vendor, Sheets("Sammanställning").Range("a1:a90"), 0)   'DOES NOT WORK. Vendor is a variable with value 8077.
    I get run-time-error 1004 "Unable to get the MATCH property of the WorksheetFunction class"
    Any idea why I can´t use the variable Vendor as lookup_value in the MATCH function?
    Last edited by mccalle; 02-23-2013 at 07:40 AM.

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