+ Reply to Thread
Results 1 to 6 of 6

Comparing values in two columns, and highlight if not equal

  1. #1
    Registered User
    Join Date
    04-15-2008
    Posts
    17

    Comparing values in two columns, and highlight if not equal

    Hi all:


    I thank all of you for your previous help in other threads.

    I have a simple macro problem. I have two columns (i.e. Columns A & E) with values than can be either numbers or strings.

    I would like to know of a macro that can compare both columns to see is the values are equal, and if they are not, it would highlight the value in column B (the would be the wrong value) and would do this for several rows (a number of rows I can change when I use this macro in different sheets)

    Thank you all for your help

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

    Select column B and go to Format|Conditional Formatting

    Cell Value Is >> Equal to >> =A1

    Click Format and choose the highlight colour from Pattern tab.
    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
    Registered User
    Join Date
    04-15-2008
    Posts
    17
    Hi NBVC:

    Thanks for the response.

    I made a mistake in my previous post. "I'm comparing columns B & E, and if the values in each row are not the same (number or strings), the color of the cell for that value in Column B should change to red (or any other color)".

    I could use Conditional Formatting as you mentioned, but I need a macro because this is actually a file I'll send to a friend who only needs to click on button, and the process is done automatically. Also I would like to see how is that done using VB code so I can learn a little bit more of Excel Macro and probably tweak it later on for a little different scenario.

    If you (or anyone) could help me with this I'd appreciate it.

    Thanks

  4. #4
    Registered User
    Join Date
    04-15-2008
    Posts
    17
    If somebody could help me with this question I'd appreciate it.


    Thanks

  5. #5
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi vmc62,

    This code will work down Col B, compare its value with Col E and if the same will turn the cell in Col B red.

    Please Login or Register  to view this content.
    Does that do what you want?
    Hope this helps

    Seamus

  6. #6
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129
    You can use Conditional Formatting for this. Change a little the condition in NBVC's post:

    Formula Is>> =A1<>E1

    And change the format such as fill color
    Last edited by ptm0412; 07-14-2008 at 09:30 PM.
    Oldman Chatting: [email protected] Mailing: [email protected]

+ 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