+ Reply to Thread
Results 1 to 9 of 9

Cell color change if value is = or > or < compare with previous cell

  1. #1
    Registered User
    Join Date
    12-06-2009
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    15

    Cell color change if value is = or > or < compare with previous cell

    In my spread sheet attached, Cell A1 is linked with another application and updates value very frequently.
    .
    Macro attached automatically copies Cell A1 value and paste into next available empty cell every 5 seconds.
    .
    What I need to change cell color every time if cell value is = or > or < then previous cell.
    .
    If next cell value is > then previous cell then color should be Blue
    If next cell value is < then previous cell then color should be Red
    If next cell value is = to previous cell then color should be Yellow
    .
    Please see code I am using in macro:
    .
    Please Login or Register  to view this content.
    Any help will be appreciated.
    .
    Regards,
    Attached Files Attached Files
    Last edited by Cutter; 07-28-2012 at 09:28 PM. Reason: Added code tags

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Cell color change if value is = or > or < compare with previous cell

    Hi Cityguy100005,

    Try this in the Worksheet:

    Please Login or Register  to view this content.
    Last edited by Cutter; 07-28-2012 at 09:29 PM. Reason: Added code tags
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    12-06-2009
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Cell color change if value is = or > or < compare with previous cell

    Hi xladept,

    thanks for your reply. I tried but seems like i am doing wrong. I am totally new to macros, Would you please kind enough to tell me where i have to place these code?

    i am using full macro code as below:
    .
    Please Login or Register  to view this content.
    .
    Regards,
    Last edited by Cutter; 07-29-2012 at 08:22 AM. Reason: Added code tags

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Cell color change if value is = or > or < compare with previous cell

    @ cityguy10005

    Please notice that code tags have been added to your post(s). Having been a member for over 3 years you should be aware that the forum rules require them so please add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Cell color change if value is = or > or < compare with previous cell

    Hi Cityguy10005,

    You place that code right in the Worksheet where it will be used - in the visual basic editor there is a list of the the Worksheets followed by the Workbook itself - click on your Worksheet where this will happen and paste the code in the Worksheet module - not the standard module that you've shown in your post.

    Here's a copy of your book with the code in the correct place:CityGuy100005.xls
    Last edited by xladept; 07-29-2012 at 03:03 PM.

  6. #6
    Registered User
    Join Date
    12-06-2009
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Cell color change if value is = or > or < compare with previous cell

    hi xladept,
    .
    Works perfect. Appreciate it.
    .
    what do i have to change if i want to include multiple culumns.
    First row of all the columns are same like A1.
    .
    Best regards,

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Cell color change if value is = or > or < compare with previous cell

    Hi Cityguy100005,

    If you want specific columns just change this line:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    or if they're all to get that treatment remove:

    Please Login or Register  to view this content.
    and one of the "End If"'s at the end.

  8. #8
    Registered User
    Join Date
    12-06-2009
    Location
    New York, US
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Cell color change if value is = or > or < compare with previous cell

    xladept,
    .
    thats perfect. thanks for your time and help.
    .
    best regards,

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Cell color change if value is = or > or < compare with previous cell

    You're welcome!

+ 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