+ Reply to Thread
Results 1 to 10 of 10

vba code to change the cell color by looking in a range that contains the color index valu

  1. #1
    Registered User
    Join Date
    03-26-2011
    Location
    York, PA
    MS-Off Ver
    Excel 2010
    Posts
    3

    vba code to change the cell color by looking in a range that contains the color index valu

    I am trying to write a vba to change the cell color by looking in a range that contains the color index value.
    example:

    Range B2 thru B500 have a value lets say "America" and in range z1 thru aa10 there is a table that contains the name in column z (america) and color index value in column aa (6).

    So if cell B3 = America then the color that cell should be 6 (which is yellow)

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: vba code to change the cell color by looking in a range that contains the color index

    I'm not sure if I understood you correctly but try this macro.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: vba code to change the cell color by looking in a range that contains the color index

    Hi ckklconner,

    here's another way (if I understood you correctly):

    Please Login or Register  to view this content.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: vba code to change the cell color by looking in a range that contains the color index

    Another way:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    03-26-2011
    Location
    York, PA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: vba code to change the cell color by looking in a range that contains the color index

    Thanks that work, How can I make it so the color change is immediate after the data is entered into column B?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: vba code to change the cell color by looking in a range that contains the color index

    Sorry, my fault, mis-read.

    Please Login or Register  to view this content.

    Regards, TMS

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: vba code to change the cell color by looking in a range that contains the color index

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  8. #8
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: vba code to change the cell color by looking in a range that contains the color index

    Quote Originally Posted by TMShucks View Post
    Sorry, my fault, mis-read.

    Please Login or Register  to view this content.

    Regards, TMS
    Nice to see different solutions to a problem!
    ckklconner, only change the line "Target.Interior.Color = _" to "Target.Interior.ColorIndex = _" if you use the color index values.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: vba code to change the cell color by looking in a range that contains the color index

    @berlan: thanks for the rep


    Regards, TMS

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: vba code to change the cell color by looking in a range that contains the color index

    @ckklconner: thanks for the rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. change fill color of a range of cells based on color of a cell?
    By DarMelNel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 04:48 PM
  2. Set cell background color by color index
    By Ms Bean in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-27-2013, 03:17 AM
  3. Code: return the color index of a colored cell
    By dpopov in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-13-2012, 07:48 AM
  4. VBScript to change color of target if range color is same
    By matt.murray in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-02-2008, 03:11 PM
  5. [SOLVED] I want to chage a whole rows text color based on single cell valu.
    By thediamondfam in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-14-2005, 11:51 AM

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