VBA example - Excel 2007: set Tab color of Excel sheet


VBA code to set Tab color of Excel sheet

In this VBA example, you will learn VBA code using a while loop to set the colors of sheet tabs when your Excel worksheet is active.

To run this VBA example code,  you will need to copy and paste the VBA code(below) to the  block of Worksheet_Activate() procedure.

VBA for Excel: VBA example code to set the colors of Sheets Tabs

VBA code for this example:


Option Explicit
Private Sub Worksheet_Activate()
   
 
Dim i As Integer
   
  
i = 1
   
  
For i = 1 To Worksheets.Count
    
   
Worksheets(i).Tab.ColorIndex = i + 10
         
  
Next

End Sub

Comments

Comments

Name:
Comment:
Enter the text:
CAPTCHA image




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.