Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Excel Macro to change the tab color of a worksheet


Change excel sheet tab colour using VBA with RGB Codes

Sub ChangeTabColor()

    Dim wb As Workbook

    Dim sh As Worksheet

    Dim newSheetName As String

    newSheetName = "My New Sheet"

    Dim fPath As String

    fPath = "C:\Users\Desktop\myfile.xlsx"

    Set wb = workbooks.Open(Filename:=fPath)

    ' delete first worksheet

    Set sh = wb.Worksheets(1)

    ' refer the color indexes and actual colors

    ' in the below image

    sh.Tab.ColorIndex = 1

    ' you can also use RGB format for defining the color code

    sh.Tab.Color = RGB(255, 0, 300)

    End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us