+ Reply to Thread
Results 1 to 6 of 6

Find Match Based on Values on Multiple Columns

  1. #1
    Registered User
    Join Date
    06-14-2019
    Location
    KG
    MS-Off Ver
    2013
    Posts
    5

    Find Match Based on Values on Multiple Columns

    Hi everyone,

    I had a trouble to get the row number of row that has match based on values on multiple columns. The formula Application.Match(strSearch, searchRange, 0) works for a single value match. I am looking to do something like this Application.Match(strSearch1 & strSearch2 , searchRange1 & searchRange2, 0) but it does not work.

    In the Excel itself, we can use MATCH(A1&A2,A1:A10&B1:B10,0), so I can write Evaluate("MATCH(A1&A2,A1:A10&B1:B10,0)"). But, I do not have a fixed search range, I do not want it to always be A1:A10 and B1:B10, I need a dynamic range, such as from the first row to the last non-blank row, and it will change according to different data. So I need to find the last non-blank row using a VBA formula, and then include it in the range. But I could not find a way to write the formula, it always gives me a Syntax error.

    Thank you for your help!!

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

    Re: Find Match Based on Values on Multiple Columns

    Sounds strange though...MATCH(A1&A2
    Something like
    Please Login or Register  to view this content.
    Where LastR is the last row of Col.A or Col.B

  3. #3
    Registered User
    Join Date
    06-14-2019
    Location
    KG
    MS-Off Ver
    2013
    Posts
    5

    Re: Find Match Based on Values on Multiple Columns

    Thank you jindon!!

    Your code works very well! However, I actually wants to match for a string that is defined inside VBA itself, not referencing to cell A1 and A2 in the Excel Workbook.

    [IN VBA]
    a="FIRST"
    b="SECOND"

    I tried something like
    Evaluate("MATCH(" & """ & a & """" & "&" & """ & d & """ & ",A1:A" & LastR & "&B1:B" & LastR & ",0)")

    But it does not work..

    Do you know why? Thank you very much!!

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

    Re: Find Match Based on Values on Multiple Columns

    Try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-14-2019
    Location
    KG
    MS-Off Ver
    2013
    Posts
    5

    Re: Find Match Based on Values on Multiple Columns

    Hi Jindon,

    Yes your code works thankyouu! I also just found out that I can use this formula

    Evaluate("MATCH(" & """ & a & """" & "&" & """ & d & """ & ",A1:A" & LastR & "&B1:B" & LastR & ",0)"), but changing the """ into chr(34) instead.

    Is this because VBA reads the double quote in a certain way that it interprets my previous code wrongly?

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

    Re: Find Match Based on Values on Multiple Columns

    Inside Brackets of Evaluate method should be String that you enter the formula in a cell.

    You should have opening " and ending ", so any " used as A string must be escaped by another set of ".

    Match("blahblah",A1:B10&B1:B10,0)
    Becomes
    "Match(""blahblah"",A1:A10&B1:B10)"

+ 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. Replies: 4
    Last Post: 02-04-2019, 06:22 PM
  2. Find duplicates in 2 columns and match values
    By alex_uk in forum Excel General
    Replies: 1
    Last Post: 05-28-2018, 09:57 AM
  3. Find Unique Values Based On Multiple Columns
    By aimone111 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-08-2016, 05:22 AM
  4. Using Sumif() to find cell with match values in two columns
    By my2108 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2015, 03:14 AM
  5. Find a match from multiple columns
    By hermoraunio in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-19-2014, 08:23 AM
  6. [SOLVED] Find count of Unique or Duplicate Values based on Concatenated values in 2 columns
    By bdicarlo1 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-03-2014, 12:42 AM
  7. [SOLVED] Distribute values in columns based on match between two other columns
    By hydrgal in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-15-2013, 04: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