Tab Object Example

The following routine changes the tab color for all budget worksheets in a workbook based on a setting in a custom property for each worksheet:

Sub ColorBudgetTabs()

Dim bBudget As Boolean Dim oCustomProp As CustomProperty Dim oCustomProps As CustomProperties Dim wks As Worksheet

'Loop through each worksheet in this workbook For Each wks In ThisWorkbook.Worksheets

'Loop through all of the custom properties ' for the current worksheet until the ' "IsBudget" property name is found For Each oCustomProp In wks.CustomProperties If oCustomProp.Name = "IsBudget" Then 'Grab its value and exit the loop bBudget = CBool(oCustomProp.Value) Exit For End If Next oCustomProp

'Use the value in the custom property to determine

' whether the tab should be colored.

If bBudget Then wks.Tab.ColorIndex = 20 'Light blue

Next wks

End Sub

Was this article helpful?

0 0
The Accidental Blogging Millionaires

The Accidental Blogging Millionaires

Get Inspired By The Most Popular Bloggers Online! If You Want To Skyrocket Your Success With Business And Improve Your Overall Life You Need To Have A Look At The Accidental Blogging Millionaires! Business can be a fight, particularly when you’re trying to establish one online and like all fights, to succeed you must find the winning techniques and apply them.

Get My Free Ebook


Post a comment