+ Reply to Thread
Results 1 to 11 of 11

Match a concatenated value in a concatenated list in a vba function

  1. #1
    Registered User
    Join Date
    12-06-2019
    Location
    Romania
    MS-Off Ver
    2016
    Posts
    22

    Match a concatenated value in a concatenated list in a vba function

    Hello,

    I am using an match fomula to get a row: Match(nr1&nr2, nr1list&nr2list, 0) -- this works perfectly in excel.

    But once i try this same in an excel vba functions i get an error and do not know how to fix it.

    dim nr1, nr2 as string
    dim nr1list, nr2list as range

    nr_row = Worksheet.Function.Match(nr1 & nr2 , nr1list & nr2list , 0)

    I was thinking of using a match or find to get the row, because my list can go up to 1000 rows and i need the function in every row. and was thinking if i use a "for each" that will just slow down the file.

    Does anyone have a idea ?

    Thank you.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Match a concatenated value in a concatenated list in a vba function


    Hi,

    use Application.Match …

  3. #3
    Registered User
    Join Date
    12-06-2019
    Location
    Romania
    MS-Off Ver
    2016
    Posts
    22

    Re: Match a concatenated value in a concatenated list in a vba function

    Does not work, the function exits because of an error.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Match a concatenated value in a concatenated list in a vba function


    The variable must be Variant and you must control its result via IsError or IsNumeric VBA function …

  5. #5
    Registered User
    Join Date
    12-06-2019
    Location
    Romania
    MS-Off Ver
    2016
    Posts
    22

    Re: Match a concatenated value in a concatenated list in a vba function

    This is what it starts like

    What the function needs to do.
    1. From current week, get previous week.
    2. Find the employee from previous week
    3. See if the info from previous week's row matches with current weeks row, if not get column header name.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-06-2019
    Location
    Romania
    MS-Off Ver
    2016
    Posts
    22

    Re: Match a concatenated value in a concatenated list in a vba function

    I managed to finish the function but needed a helper column that concatenates the 2 column info.

    Is there a way to do it without the helper column ?

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Match a concatenated value in a concatenated list in a vba function


    Yes !

    Follow the top yellow banner in order to attach a sample workbook and well elaborate your need …

  8. #8
    Registered User
    Join Date
    12-06-2019
    Location
    Romania
    MS-Off Ver
    2016
    Posts
    22

    Re: Match a concatenated value in a concatenated list in a vba function

    I posted the whole code above, why do u need a workbook ?

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Match a concatenated value in a concatenated list in a vba function


    'cause we are not on some mind readers forum ! …

    So try under VBA the same formula than in the helper column but for both columns range within a variable array …

  10. #10
    Registered User
    Join Date
    12-06-2019
    Location
    Romania
    MS-Off Ver
    2016
    Posts
    22

    Re: Match a concatenated value in a concatenated list in a vba function

    If i do not use the helper column ( concatenate 2 cell, and fill down ), i need something like this: prev_week_row = Application.Match(prev_week & empl_id, week_list & empl_list, 0) , but this does not work.

    If i create a concatenated column of week_list and empl_list => i get week_list_ID and then i can use the line: prev_week_row = Application.Match(prev_week & empl_id, week_list_ID, 0) , this works perfectly.

    My question was is there a way to concatenate the 2 lists in VBA that would not slow down the file ? ( not to loop true each item )

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

    Re: Match a concatenated value in a concatenated list in a vba function

    Quote Originally Posted by Rolly_Sefu View Post
    Hello,

    I am using an match fomula to get a row: Match(nr1&nr2, nr1list&nr2list, 0) -- this works perfectly in excel.
    Then
    Please Login or Register  to view this content.

+ 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] Transform User Defined Function to Sub (Filter Partial Concatenated Match) SOS
    By therealdees in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-10-2021, 12:14 PM
  2. Replies: 13
    Last Post: 04-20-2021, 06:08 PM
  3. [SOLVED] Group consecutive numbers in a concatenated list
    By Excel-lecxE in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-15-2018, 11:21 AM
  4. [SOLVED] Concatenated list of years for each winner
    By neil40 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 07-25-2017, 09:25 AM
  5. [SOLVED] Having trouble trying to use index match with a concatenated name.
    By john dalton in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-12-2016, 08:54 AM
  6. vba to Match concatenated values in concatenated columns
    By bjurick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2012, 03:45 PM
  7. Find an exact duplicate match on concatenated cells
    By madball87 in forum Excel General
    Replies: 2
    Last Post: 10-04-2011, 06:07 AM

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