+ Reply to Thread
Results 1 to 7 of 7

Match a cell with dynamic range (multiple columns)

  1. #1
    Registered User
    Join Date
    07-08-2010
    Location
    atlanta
    MS-Off Ver
    Excel 2003
    Posts
    26

    Match a cell with dynamic range (multiple columns)

    With the code below I am able to match cell A1 in worksheet:"DataByCC" with values range on column A to the last used cell on that column (col A)
    If there is a match then I copy the entire row on the other Workshhets to DataByCC

    The only Edit/Change I am trying to do is do the match (cell A1 in DataByCC) with columns A through F,,,if there is a match just copy the entire row to "DataByCC"

    I hope someone can help
    Thanks
    bg

    Please Login or Register  to view this content.
    Last edited by davesexcel; 08-19-2011 at 07:54 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Match a cell with dynamic range (multiple columns)

    try this: I'm not really able to test it as I cant reproduce your workbook but it should work or give you the idea to use:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Match a cell with dynamic range (multiple columns)

    Quote Originally Posted by bgonen
    With the code below I am able to match cell A1 in worksheet:"DataByCC" with values range on column A to the last used cell on that column (col A)
    The above is not strictly true (first sheet only) but the logic is sound in so far as every value in DataByCC!A:A currently matches that of DataByCC!A1 and thus the Match against DataByCC!A:A is effectively the same as testing =DataByCC!A1

    Regards your question, without wishing to modify your approach too much, if the intention is to test only against DataByCC!A1 why not invert the Logic such that you match DataByCC!A1 against A:F on the sheet/row being iterated ?

    Please Login or Register  to view this content.
    Persisting with your existing Match:

    Please Login or Register  to view this content.
    given the new A:F test is likely to lead to erroneous results as not all the values in DataByCC!A:A will match that of DataByCC!A1

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Match a cell with dynamic range (multiple columns)

    bgonen,

    Your post does not comply with Rule 8 of our Forum RULES.

    Cross-posting is when you post the same question in other forums on the web.

    You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post(s).

    Read this to understand why we ask you to do this

  5. #5
    Registered User
    Join Date
    07-08-2010
    Location
    atlanta
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Match a cell with dynamic range (multiple columns)

    Thank you very much

    I have made few tests and I'm pretty sure your revised suggestion work fine
    Thank you so much for the quick help
    bg

  6. #6
    Registered User
    Join Date
    07-08-2010
    Location
    atlanta
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Match a cell with dynamic range (multiple columns)

    Hello again DonkeyOte

    I was trying to learn your code: vTemp but could not find any material about it

    looking specifically to the code: If IsNumeric(Application.Match(vTemp, .Resize(, 6), 0)) Then,,,

    Can you point me to specific reference/s or maybe shortly explain the code

    Thanks again for your very useful help
    bg

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Match a cell with dynamic range (multiple columns)

    vTemp is a variable (variant type) to which the value in DataByCC!A1 is assigned

    Quote Originally Posted by bgonen
    looking specifically to the code: If IsNumeric(Application.Match(vTemp, .Resize(, 6), 0)) Then,,,

    Can you point me to specific reference/s or maybe shortly explain the code
    The above tests to see if vTemp can be found (numeric result if found) in ws!An:Fn where ws is the worksheet being iterated and n the row being iterated.

+ Reply to Thread

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