+ Reply to Thread
Results 1 to 15 of 15

Find Matching values from single row

  1. #1
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Find Matching values from single row

    I have a "master"row that contains a fixed number of values 10. I also have about 60 rows of the same length that i need to search if there are matching values from this "master" row. I would like to highlight the matching values.

    Is there a quick way of doing this using functions or VBA. i have thought of using a nested for-loop...

    for (int i = 1 to 10 )
    for (int j = 1 to 36)
    for (int k= 1 to 10)
    if master[i] = Rest[j][k]
    Rest[j][k].background = yellow
    end if
    end if
    end if

    Im familiar with programming but having difficulty transferring this to Excel VBA

    Any help and or Advice greatly appreciated!
    Last edited by simon123; 02-17-2011 at 10:09 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Matching values from single row

    Does it matter if the numbers are not in the same column?

    You can use Conditional formatting.

    So assuming the Master row is A1:J1 and the 60 other rows are A2:J61, then

    Select A2:J61 and go to Format|Conditional formatting.

    Choose Formula Is from drop down menu

    Enter formula: =MATCH(A2,$A$1:$J$1,0)

    Note the $ signs...

    Then click Format and choose colour from pattern tab.

    If the match must also be in the same column, then use the conditional formula:

    =A2=A$1
    Last edited by NBVC; 02-15-2011 at 05:03 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,038

    Re: Find Matching values from single row

    I would have thought you could use Conditional Formatting for this.

    Please post a sample workbook with some typical data.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Matching values from single row

    I did show Conditional formatting solutions....

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,038

    Re: Find Matching values from single row

    @NVBC: yes - you were writing while I was still thinking ... ;-)

  6. #6
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Find Matching values from single row

    Quote Originally Posted by NBVC View Post
    Does it matter if the numbers are not in the same column?

    You can use Conditional formatting.

    So assuming the Master row is A1:J1 and the 60 other rows are A2:J61, then

    Select A2:J61 and go to Format|Conditional formatting.

    Choose Formula Is from drop down menu

    Enter formula: =MATCH(A2,$A$1:$J$1,0)

    Note the $ signs...

    Then click Format and choose colour from pattern tab.

    If the match must also be in the same column, then use the conditional formula:

    =A2=A$1
    Much appreciated!...it seems to do the work, However im trying to be ambitious and would like the "master" row to be rows of a variable length...i have thus tried

    Enter formula: =MATCH(A2,$A$1:$J$13,0)
    but it doesnt seem to format.
    I had wanted to enter the values of rows 2-13 anytime is there a way to fix this formula or do i have to do this differently....this is assuming the "axtra" master rows are entered on a daily basis and would like to see the formatting change daily without manual intervention

    Thanks for shading the light

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Matching values from single row

    Match only works with 1 row or 1 column ranges....

    try instead:

    =COUNTIF($A$1:$J$13,A14)>0

    where A14 is first cell in rows to match up to the top 13 rows (not sure why you have A2 in your attempt? Are you checking for duplicates within A1:J13?)

  8. #8
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Find Matching values from single row

    Quote Originally Posted by NBVC View Post
    Match only works with 1 row or 1 column ranges....

    try instead:

    =COUNTIF($A$1:$J$13,A14)>0

    where A14 is first cell in rows to match up to the top 13 rows (not sure why you have A2 in your attempt? Are you checking for duplicates within A1:J13?)
    Say no more!!..you"ve HIT THE NAIL ON HEAD....thats seems to work for me just hope u not my BOSS undercover

    i know im pushing it but can i continously activate this with a button on a daily basis?
    Last edited by simon123; 02-15-2011 at 06:23 PM.

  9. #9
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Find Matching values from single row

    Quote Originally Posted by simon123 View Post
    Say no more!!..you"ve HIT THE NAIL ON HEAD....thats seems to work for me just hope u not my BOSS undercover
    i know im pushing it but can i continously activate this with a button on a daily basis?

    =CountIF function has worked, thanks to NBVC,
    not sure if this complicates the issue, this countif function has to be based on a criteria for every search row is a value next to the end of the row i.e. if criteria not met NO formating is done, is there a way to include this in the function?...ideally
    If (criteria = met )
    format
    else
    nothing happens
    endif
    see attached of the image
    Attached Files Attached Files

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Matching values from single row

    I'm not making sense of this revision. You have 3 differently coloured columns and each cell has the word criterea... what exactly is supposed to be checked for?

  11. #11
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Find Matching values from single row

    Quote Originally Posted by NBVC View Post
    I'm not making sense of this revision. You have 3 differently coloured columns and each cell has the word criterea... what exactly is supposed to be checked for?
    At the moment if i populate row A3:J3 with values then matching values in A20:J:20 are automatically formatted. What i want to do is before i format the values in A20:J20, i must first check the value in K20 if this value is =0 dont format and if =1 then format

    before formating values in A24:J:24 first check value in K24..and so forth so in other words before formatting values in a row check the "key" whick is always the value in the K-column.

    ****ignore the colours in the attachment i this this way is simpler

    I hope this sounds clearer
    Last edited by simon123; 02-16-2011 at 10:42 AM.

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Matching values from single row

    Quote Originally Posted by simon123 View Post
    At the moment if i populate row A3:J3 with values then matching values in A20:J:20 are automatically formatted.
    Do you mean A1:J2? (ie top 2 rows)

    What i want to do is before i format the values in A20:J20, i must first check the value in K20 if this value is =0 dont format and if =1 then format
    Do you mean any row starting from Row 9 in the sample attachment?

    And we are only looking to column K to determine criteria for formatting?

  13. #13
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Find Matching values from single row

    Quote Originally Posted by NBVC View Post
    Do you mean A1:J2? (ie top 2 rows)



    Do you mean any row starting from Row 9 in the sample attachment?

    And we are only looking to column K to determine criteria for formatting?
    If i populate A3:J3 with numbers suppose there are matching values anywahere in the data set, before formatting can be done on the matching cell i have to validate this by checking the value in the 'K-cell' of the row. So yes we are looking to column K

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Find Matching values from single row

    Alright, so assuming you are entering numbers in A3:J3 and have 1's and 0's entered in K9:K34,

    Then select A9:J34 and invoke Conditional Formatting

    Formula Is >> =AND($K9=1,COUNTIF($A$3:$J$3,A9))

    Format with colour from Pattern tab.

  15. #15
    Registered User
    Join Date
    02-15-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    28

    Re: Find Matching values from single row

    Thanks NBVC!...

+ 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