+ Reply to Thread
Results 1 to 6 of 6

Thread: TAB color based on Empty cell

  1. #1
    Registered User
    Join Date
    05-26-2010
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2003
    Posts
    31

    TAB color based on Empty cell

    Hi Guys,

    In the entire workbook I would like the sheets with D3 cell empty to show the Tabs as red so I would know they need to be filled in - any ideas?

  2. #2
    Forum Guru jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    2,573

    Re: TAB color based on Empty cell

    How about this

    Sub colortab()
    Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
            If ws.Range("D3") = "" Then ws.Tab.Color = 255
        Next ws
    End Sub

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: TAB color based on Empty cell

    Try this, it goes in the WorkBook Module...

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
        For Each Sh In ActiveWorkbook.Worksheets
            If Sh.Range("D1") = "" Then
                Sh.Tab.ColorIndex = 3
            Else: Sh.Tab.ColorIndex = xlNone
            End If
        Next Sh
    End Sub

  4. #4
    Registered User
    Join Date
    05-26-2010
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: TAB color based on Empty cell

    Quote Originally Posted by davesexcel View Post
    Try this, it goes in the WorkBook Module...

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
        For Each Sh In ActiveWorkbook.Worksheets
            If Sh.Range("D1") = "" Then
                Sh.Tab.ColorIndex = 3
            Else: Sh.Tab.ColorIndex = xlNone
            End If
        Next Sh
    End Sub
    Thank you jeffery and Dave! EXcellent.

    I have gone with Daves, as Jeffreys would not work for me. If I wanted to exclude one sheet only in the book (called averages) would there be a way around it?

    this is magic , thankyou

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843

    Re: TAB color based on Empty cell

    Reset The averages sheet to no color before you use the code
    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
        For Each Sh In ActiveWorkbook.Worksheets
            If Sh.Name <> "averages" Then
                If Sh.Range("D1") = "" Then
                    Sh.Tab.ColorIndex = 3
                Else: Sh.Tab.ColorIndex = xlNone
                End If
            End If
        Next Sh
    End Sub

  6. #6
    Registered User
    Join Date
    05-26-2010
    Location
    Auckland, NZ
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: TAB color based on Empty cell

    Dave,

    thank you soooooooooooo much - Im going to have a great weekend because of this! thank you !!!!

+ 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.2.0