+ Reply to Thread
Results 1 to 5 of 5

Change cell color depending on cell color, error in code

  1. #1
    Registered User
    Join Date
    07-02-2014
    Location
    Sweden
    MS-Off Ver
    Office 2013
    Posts
    17

    Unhappy Change cell color depending on cell color, error in code

    I've trying to create a macro that changes all the grey cells to yellow cells. I've created a code that I think should work but it doesn't and I can't find what I've done wrong.
    Any help would be greatly appreciated. The document I want to change the cells colors in has some merged cells that why I have the extra functions in the bottom of the code.

    Please Login or Register  to view this content.
    Best Regards
    Lars

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Change cell color depending on cell color, error in code

    You're setting a variable to the color index, but not setting the cell to be that color index

    Please Login or Register  to view this content.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    07-02-2014
    Location
    Sweden
    MS-Off Ver
    Office 2013
    Posts
    17

    Re: Change cell color depending on cell color, error in code

    Thank you for the fast reply.

    I tried making the recommended change, but now it just gets rid of the fill and leaves the cell blank. It doesn't change the color to nr 36. Any tips?

    Edit: It gets of the fill in all colored cells not only cells with color 15

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Change cell color depending on cell color, error in code

    You will need to add c.Interior.ColorIndex = iColorIndex before the next c in your code, you need the rest of the code.

  5. #5
    Registered User
    Join Date
    07-02-2014
    Location
    Sweden
    MS-Off Ver
    Office 2013
    Posts
    17

    Re: Change cell color depending on cell color, error in code

    Thanks for the help it worked perfectly

+ 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. [SOLVED] vba code to change the cell color by looking in a range that contains the color index valu
    By ckklconner in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-24-2013, 09:15 AM
  2. Change tab color depending on cell value
    By rirons04 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-01-2011, 02:34 PM
  3. Replies: 3
    Last Post: 07-08-2010, 06:48 PM
  4. [SOLVED] How do I change the color of a cell depending on the result of the function in that cell
    By Mo Childs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-02-2005, 06:20 PM
  5. Change color depending on cell value
    By Gary Paris in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2005, 08:08 PM

Tags for this Thread

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