Tab Object

Sheet tabs at the bottom of an Excel chart sheet or worksheet are represented by the Tab object. Excel 2002 has a new feature that allows you to change the color of sheet tabs by using the Color or ColorIndex properties of the Tab object. The Color property requires that you use the RGB function to create a color value. For example, to set the Sheet1 tab color to purple, use the following statement:

ActiveWorkbook.Worksheets(1).Tab.Color = RGB(128, 0, 255)

Sub ColorTabs()

Dim wks As Worksheet Dim i As Integer i = 5

For Each wks In ThisWorkbook.Worksheets

If wks.Tab.Colorlndex = xlColorlndexNone Then wks.Tab.Colorlndex = i i = i + 1 End If Next End Sub

0 0

Post a comment