PDA

View Full Version : Coloring of the tab of a worksheet



chamster
09-06-2007, 02:48 AM
I've colored a tab of a sheet and it looks nice. The thing is that when the tab is selected, the color turns white (the original color stays as an underline). Is that behavior avoidable?

I mean - the font getting bold is just fine, the color of the text might change as well but the coloring of the background of the tab is a little bit ugly in my opinion, not to mention confusing...

rory
09-06-2007, 04:29 AM
No it's not. (other than changing the Windows colour settings)

chamster
09-06-2007, 04:47 AM
I was going to say :"Thanks. Now, how do i change the Windows color settings from Excel?" but it just stroke me that your answer will be "You can't, buddy, drop dead, eat shorts etc.!". Thanks anyway... :)

rory
09-06-2007, 05:08 AM
No, my answer is: "You do it using Windows API calls , but I would really, really, really, REALLY, not recommend it. Not only do users not like you messing with their desktops, but the entire worksheet background would turn the same colour!

Charlize
09-06-2007, 05:13 AM
I tend to use this little routine. Worksheet tab one is yellow, two is red, three is black. When workbook opens, the colourvariable is set to 6 and on changing sheets the sheetdestination tab is set to white. On leaving, the color is restored.Option Explicit
Public vcolour As Long
Private Sub Workbook_Open()
'yellow
vcolour = 6
Worksheets(1).Tab.ColorIndex = 6
Worksheets(2).Tab.ColorIndex = 3
Worksheets(3).Tab.ColorIndex = 1
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Tab.ColorIndex <> 7 Then
vcolour = Sh.Tab.ColorIndex
End If
Sh.Tab.color = vbWhite
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Sh.Tab.ColorIndex = vcolour
End Sub