+ Reply to Thread
Results 1 to 5 of 5

Change Colour of 3 Cells based on Value of Other Cell

  1. #1
    Registered User
    Join Date
    11-02-2010
    Location
    Cirencester, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Change Colour of 3 Cells based on Value of Other Cell

    Hi,

    I'm trying to create a Macro which will change the interior colour of 3 cells based on the value of another cell. I can't use Conditional Formatting as our Sales force use Office 2003 and therefore I can only have 3(4) different rules however I need 5. I have tried many attempts and scoured the net however have had no luck so far. Here is my best attempt at a Macro so far:

    Please Login or Register  to view this content.

    You'll be able to see I am searching for a independent text string "baaa" and then once found offsetting by 8 cells to the right. I use independent text strings so that if somebody inserts a row it will still find and offset to the correct cell.

    Does anyone see anything wrong with the above macro as it simply isn't working!

    Kind Regards,
    Harry Seager

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Change Colour of 3 Cells based on Value of Other Cell

    It works for me. But why in the worksheet change event? Is B1=1?

  3. #3
    Registered User
    Join Date
    08-12-2010
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Change Colour of 3 Cells based on Value of Other Cell

    Quote Originally Posted by hazza147 View Post
    Hi,

    I'm trying to create a Macro which will change the interior colour of 3 cells based on the value of another cell. I can't use Conditional Formatting as our Sales force use Office 2003 and therefore I can only have 3(4) different rules however I need 5. I have tried many attempts and scoured the net however have had no luck so far. Here is my best attempt at a Macro so far:

    Please Login or Register  to view this content.

    You'll be able to see I am searching for a independent text string "baaa" and then once found offsetting by 8 cells to the right. I use independent text strings so that if somebody inserts a row it will still find and offset to the correct cell.

    Does anyone see anything wrong with the above macro as it simply isn't working!

    Kind Regards,
    Harry Seager

    Hello

    Here's some alternative code you can try:


    Please Login or Register  to view this content.

    If yours works though use it.


    Quote Originally Posted by StephenR View Post
    It works for me. But why in the worksheet change event? Is B1=1?
    This lad is right. Check if B1 = 1 (whatever that's about). Also if the sheet has a lot of data on it using the worksheet change could slow things horribly.
    Last edited by ReportMaker; 11-17-2010 at 12:28 PM. Reason: Mistake

  4. #4
    Registered User
    Join Date
    11-02-2010
    Location
    Cirencester, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Change Colour of 3 Cells based on Value of Other Cell

    Quote Originally Posted by StephenR View Post
    It works for me. But why in the worksheet change event? Is B1=1?
    The setup is as follows; I use a combo box which is linked to Cell B1. Therefore depending on what value is selected B1 will have a value from 1-5. Each different value from 1-5 needs a different colour and therefore I use 5 different macros ie. If B1=1 then..., if B1=2 then...

    Unfortunately the code provided doesn't fulfill my needs... plus as a VBA amateur I'm struggling to understand what half of it means!

    I use the search string 'baaa' to find the row location of where I would like highlighed a little like a Match function, then I offset by 8 columns to get to the box I need highlighting.

    Thanks for your help so far.

  5. #5
    Registered User
    Join Date
    11-02-2010
    Location
    Cirencester, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Change Colour of 3 Cells based on Value of Other Cell

    Problem solved. Used the following Macro in the worksheet:

    Please Login or Register  to view this content.

+ 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