Name

Tab Object

Synopsis

Path: Application  --  Chart - Tab
               

Object

Properties

Tab

  • Color( ) As Variant

  • ColorIndex( ) As XlColorIndex

The ability to change the color of worksheet and chart tabs is new for Excel XP. This is done through the user interface by right-clicking on a tab and choosing Tab Color from the popup menu. To change the color programmatically, we can write code such as:

Worksheets("Sheet2").Tab.Color = vbGreen

The Tab object is returned by the Tab property of the Worksheet and the chart objects, and it has Color and ColorIndex properties that can set the color.

Get Writing Excel Macros with VBA, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.