+ Reply to Thread
Results 1 to 4 of 4

create a simple macro that changes fill color

  1. #1
    Registered User
    Join Date
    02-08-2008
    Posts
    2

    create a simple macro that changes fill color

    Hi guys! Found this forum today, it looks good!

    It's been a while ago since I've been working with excel, and I forgot alot of things. I really need help creating a macro that changes the fill color of a cell depending on the value in another cell.

    I have 3 rows. 1 is ID number, could be anything. 2 is Value A and 3 is Value B.

    I have 4 ranges that I need to use.
    Range 1: AWAY (FILL WITH BLUE)
    Range 2: 0 to -99999 (FILL WITH RED)
    Range 3: 30 to 0 (FILL WITH YELLOW)
    Range 4: 30 to 99999 (FILL WITH GREEN)


    Range 1 is priority ONE and so on. So if VALUE A = 40 and VALUE B = -10, then the FILL COLOR inn ROW 1 = RED.



    Sorry for my bad english, but I'll hope you understand what I want. I attached a copy of my .xls.


    Regards,
    Niclas
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    10-30-2007
    Location
    Norway
    MS-Off Ver
    MS Office 2007
    Posts
    345
    You don't need a macro for this. This can be done with conditional formatting. Set all cell colors to green, and use contitional formatting to change it to blue, red or yellow.

    See example file
    Attached Files Attached Files

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Quote Originally Posted by Niclas
    Hi guys! Found this forum today, it looks good!

    It's been a while ago since I've been working with excel, and I forgot alot of things. I really need help creating a macro that changes the fill color of a cell depending on the value in another cell.

    I have 3 rows. 1 is ID number, could be anything. 2 is Value A and 3 is Value B.

    I have 4 ranges that I need to use.
    Range 1: AWAY (FILL WITH BLUE)
    Range 2: 0 to -99999 (FILL WITH RED)
    Range 3: 30 to 0 (FILL WITH YELLOW)
    Range 4: 30 to 99999 (FILL WITH GREEN)


    Range 1 is priority ONE and so on. So if VALUE A = 40 and VALUE B = -10, then the FILL COLOR inn ROW 1 = RED.



    Sorry for my bad english, but I'll hope you understand what I want. I attached a copy of my .xls.


    Regards,
    Niclas
    Hi,

    You don't really need a macro, you can use Conditional Formats to achieve what you want. Format the cell in the usual way as a default of Blue, then using the 'Formula is' option set the following conditional formats in A4 and copy down,

    First condition - Green
    Please Login or Register  to view this content.
    Second condition - yellow
    Please Login or Register  to view this content.
    Third condition - Red
    Please Login or Register  to view this content.
    If you really do want a macro solution then post back.

    HTH

  4. #4
    Registered User
    Join Date
    02-08-2008
    Posts
    2
    Thanks guys! Will try this out!

    Edit: Just what I was looking for! Thanks!
    Last edited by Niclas; 02-17-2008 at 05:54 PM. Reason: It worked!

+ 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