+ Reply to Thread
Results 1 to 7 of 7

Macro to change multiple sheet tabs color based on a cell value

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    8

    Macro to change multiple sheet tabs color based on a cell value

    Hey guys,

    First time posting. I have been looking for a solution to this problem. I have a spreadsheet that reports back to cell B11 whether a specific conflict is Telephone, Gas, Water, Power, Sanitary, Storm, Cable TV, or Unknown. What I want to do is change the color of the sheet tab based on the value in cell B11. I have tried a few different things but nothing works right. I have a macro to sort the sheets and I would like to add this to it so when a button is pushed it sorts the sheets and colors the tabs. Here's what I have for the sorting macro.

    Please Login or Register  to view this content.
    I would greatly appreciate any help.
    Last edited by Cutter; 09-18-2012 at 07:16 PM. Reason: Added code tags

  2. #2
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Macro to change multiple sheet tabs color based on a cell value

    Since you are actually looping through the sheets multiple times, I would recommend putting this in a separate procedure and calling it after you finish sorting:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro to change multiple sheet tabs color based on a cell value

    Hey Wallyeye, thanks for replying so quickly. I tried your code didn't work for me. Would it matter that cell B11 is a formula calling data from a cover sheet?

  4. #4
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Macro to change multiple sheet tabs color based on a cell value

    I wouldn't think so, it is specifically retrieving the value in B11. I have seen it fail if the entire cell is not visible, that is you see "Tele" instead of "Telephone" because the column is not wide enough. If this is the case, you can either make the column wider, or truncate the text as:

    Please Login or Register  to view this content.
    I put the strText in so you can see what is actually being compared, just put a breakpoint on the Select statement (using F9), then run the code. When the line is reached, the IDE will stop and you can hover your mouse over strText to see its current value.
    Last edited by wallyeye; 09-11-2012 at 03:28 PM.

  5. #5
    Registered User
    Join Date
    09-05-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro to change multiple sheet tabs color based on a cell value

    Thanks Chief that did it. It works perfectly. YOU ARE THE MAN!!!

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Macro to change multiple sheet tabs color based on a cell value

    @ greywu1f

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Last edited by Cutter; 09-19-2012 at 12:12 PM.

  7. #7
    Registered User
    Join Date
    09-05-2012
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Macro to change multiple sheet tabs color based on a cell value

    Thanks cutter I will read through all the board rules and make sure I adhere. Reputation added for Wallyeye.


    EDIT by Cutter: Perfect! With your user name and my avatar we're going to be best friends!
    Last edited by Cutter; 09-19-2012 at 12:15 PM.

+ 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