+ Reply to Thread
Results 1 to 12 of 12

compare cells and highlight same

  1. #1
    Registered User
    Join Date
    01-03-2013
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    35

    compare cells and highlight same

    HI.
    active sheet contains numbers in 6 columns (A-B-C-D-E-F) and many rows. I am trying to compare the value of every cell in rows to value of cells in column K, and highlight cell if a match. I just started excel a couple of days ago, and this is what I wrote:
    excel sheet

    xltest.jpg


    ==================
    Please Login or Register  to view this content.
    =========================

    Please help.
    Thanks
    Last edited by shart2k12; 01-05-2013 at 11:16 AM. Reason: Code tags not quote tags.

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: compare cells and highlight same

    Do you mean that you want to compare each value in A:F to the value in K for each row. If yes then try
    Please Login or Register  to view this content.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    Registered User
    Join Date
    01-03-2013
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: compare cells and highlight same

    Thanks for your reply.
    It works but not completely. It does not evaluate every individual cell value in (A1-F100) to all the values in column (K). column K may have values from (K1 to K100). When I ran it, the '9' was highlighted only, other matches were not.
    Thank you again.

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: compare cells and highlight same

    Are you saying that you it isn't a check for Column K to Columns A to F in the same row but rather a check of all the values in Column K to all the values in A to F on all rows?

    If yes then try
    Please Login or Register  to view this content.
    Last edited by WasWodge; 01-05-2013 at 12:17 PM.

  5. #5
    Registered User
    Join Date
    01-03-2013
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: compare cells and highlight same

    You know I just started learning excel, so I am not sure what you're asking!
    to make it simple: we have 6 cells (row A to F: 1-2-3-4-5-6) with these values. I want to check (A-F) cell values individually against cell values in column (K: 4-21-23-45-65-33). So in this example there is only one match (4) in C1. And cell (C1) only to be highlighted.
    Thanks again for your help.

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: compare cells and highlight same

    Have a look at the edit I made to my previous post and see if that is what you require.

  7. #7
    Registered User
    Join Date
    01-03-2013
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: compare cells and highlight same

    Wow.. great!
    One small problem, it highlights everything after row 17 (actually A17 to F29 only, why?) . is there a way to prevent that? Cells are blank from row 17 on.
    Thanks again.

    It seems to highlight cells that are blank only!
    Last edited by shart2k12; 01-05-2013 at 12:52 PM.

  8. #8
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: compare cells and highlight same

    Use 2B if Column K is never longer than Column A (and obviously if it gives the correct result).

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    It highlighted up to row 29 because it looks for the last used cell on the sheet and there is obviously something in row 29
    Last edited by WasWodge; 01-05-2013 at 01:03 PM.

  9. #9
    Registered User
    Join Date
    01-03-2013
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: compare cells and highlight same

    WasWodge, thank you so much for your help. I fixed the highlight problem by adding [And c.Value <> ""]
    It is perfect now.
    Have a great day!

  10. #10
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: compare cells and highlight same

    Please note I have made an edit to my last post as I put 29 instead of 17 ...Doh

  11. #11
    Registered User
    Join Date
    01-03-2013
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: compare cells and highlight same

    The [And c.Value <> ""] seems to solve the blank cells after last row filled!
    I really appreciate your time and effort. I am new at excel & VBA.. too many things to learn!!!
    Have a great weekend!

  12. #12
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: compare cells and highlight same

    too many things to learn!!!
    Same here.
    Have a great weekend!
    ...and you too

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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