+ Reply to Thread
Results 1 to 3 of 3

VBA Syntax for WORKSHEETFUNCTION.MATCH

  1. #1
    Forum Contributor
    Join Date
    12-06-2021
    Location
    Fort Lauderdale, Florida. United States
    MS-Off Ver
    365
    Posts
    143

    VBA Syntax for WORKSHEETFUNCTION.MATCH

    Hello!

    I have the code listed below. It works perfectly to match a cell content in the "Sylvia" worksheet to the cell content in worksheet called "BackEnd" and update the information


    My Question:

    I need to modify the syntax to where the sheet "BackEnd" is now located in a different workBOOK. I'm assuming the filepath needs to be included in this code but i'm not sure how to fit it into the syntax.



    Sub UPDATE_RECORD_sylvia()
    Dim lngRow As Long

    On Error Resume Next

    lngRow = Application.WorksheetFunction.Match(Worksheets("Sylvia").Range("E8"), Worksheets("BackEnd").Range("A2:A200000"), 0)
    If Err.Number <> 0 Then
    MsgBox "This Banking ID does not exist."
    Exit Sub
    End If
    On Error GoTo 0

    'Below: The first part of the Statement defines where the Banking ID is located in the BackEnd and states what column # it should land on.
    'The second part of the statement defines the source sheet name, and the range-id to be copied over.

    Worksheets("Backend").Range("a2:a200000").Cells(lngRow, 12) = Sheets("Sylvia").Range("E13")

    End Sub


    Any help would be appreciated!!!

    Rob

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,587

    Re: VBA Syntax for WORKSHEETFUNCTION.MATCH

    You can not use WorksheetFunction across workbooks, instead use ExecuteExcel4Macro.
    e.g
    Please Login or Register  to view this content.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: VBA Syntax for WORKSHEETFUNCTION.MATCH

    You can use it across workbooks, but the workbook for any range references needs to be open.
    Remember what the dormouse said
    Feed your head

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] If WorksheetFunction.Match does not return a value, then...
    By excel_novice2019 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2019, 08:02 PM
  2. [SOLVED] WorksheetFunction match - Userform
    By Villalobos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2016, 01:31 PM
  3. Application.WorksheetFunction.Match in VBA
    By karen53 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2014, 06:32 PM
  4. [SOLVED] VBA worksheetfunction.match doesn't match DATE. Userform
    By stevnb in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-05-2012, 09:08 AM
  5. [SOLVED] Userform Match - unable to get the match property of the worksheetfunction class - Help!
    By Tayque_J_Holmes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2012, 11:01 AM
  6. Worksheetfunction.Match Issue
    By DAA in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-01-2009, 09:51 AM
  7. Application.WorksheetFunction.Match
    By TK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-06-2005, 05:05 PM

Tags for this Thread

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