+ Reply to Thread
Results 1 to 12 of 12

Set background in Cell depending on another cell's background

  1. #1
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12

    Set background in Cell depending on another cell's background

    Hello,

    In a range of cells (A1..d8) which have background set with multiple colors. Is it possible to set another range of cells (H1..K8) whith the same backgrounds as the other range and so that if one cells background changes the cell in the second range whill also change to that new color?

    kind regards,

    robbert

  2. #2
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186
    You can use the following line to copy the colors from one range to the other.

    Please Login or Register  to view this content.
    Now depends only on how or when you want the procedure to start. (eg. with a button, on events, on calculations, etc.)

    Hope it helps.

  3. #3
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12
    Thanks for the reply.

    I would like the cells to be updated whenever something changes on the worksheet, is this possible?

    kind regards

    robbert

  4. #4
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186
    Sure it is;
    Just use the "Worksheet_Change" feature inside the worksheet you want to trigger the macro:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12
    unfortunately when I run the code the fields H1..K8 stay white (no background) any ideas?

    robbert

  6. #6
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186
    It should work.
    If you send me the file I might take a quick look and maybe help you further.

  7. #7
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12
    here the file attached.

    kind regards,

    robbert
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12
    Wizz,

    my mistake it works.
    My only problem is that the range it will copy from and the range it will copy to could grow or shrink for example the range could change to a1..d4 and so also the target range. Is this also possible to be solved?

  9. #9
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186
    Yes it is possible.
    Just need to know:
    a) Is the offset amount always the same or it will always be different.
    b) The position were you start asigning the new colors is always the same or it is also different.

  10. #10
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12
    a) the offset amount will increase
    B) also the position where we start assignin the new colors will be different

  11. #11
    Forum Contributor
    Join Date
    08-02-2007
    Location
    Panama & Austria
    MS-Off Ver
    2003 & 2010
    Posts
    186
    The following procedure should help.
    To see how it works:
    1.Select the desired range you want to copy its background colors
    2.Click over the grey circle.
    3.A msgbox will popUp. Write inside the address of the cell were you want to start painting.

    Please Login or Register  to view this content.
    Now is up to you to modify it depending on your needs.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-15-2009
    Location
    obdam,hooald
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Set background in Cell depending on another cell's background

    is it possible to use named ranges in this code? The named ranges will automaticly change when coloms are added.

+ 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