Simple Question - VBA Object Name

Benzula

Board Regular
Joined
Feb 28, 2014
Messages
248
What is the VBA Object name for selecting the active sheets' tab to change its color.

Basically I want to change the color of a tab on a simple loop, but I can't select the active Tab.

Code:
Dim sheetNo As Integer


For sheetNo = 1 To Sheets.Count
   Sheets(sheetNo).Activate
    
ActiveSheet.ActivateTab.Select
    With ActiveTab
        .ThemeColor = xlThemeColorAccent2
        .TintAndShade = 0.399975585192419
    End With
    Next
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Maybe something like
Code:
Sub MM1()
Dim Sht As Worksheet
For Each Sht In Worksheets
    With Sht.Tab
        .Color = 255
    End With
Next Sht
end sub
 
Upvote 0
Something like this, changes the colour of the active sheet tab to RED
Code:
Sub activesheetcolour()
    Dim ws As Worksheet
    Set ws = ActiveWorkbook.ActiveSheet
    ws.Tab.Color = vbRed
End Sub

or in a loop
Code:
Sub activesheetcolour()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        ws.Tab.Color = vbRed
    Next ws
End Sub
 
Last edited:
Upvote 0
This worked for me in Excel 2010. No need to activate the sheets either, I commented that line out:

Code:
Dim sheetNo As Integer
For sheetNo = 1 To Sheets.Count
   'Sheets(sheetNo).Activate
    With ActiveWorkbook.Sheets(sheetNo).Tab
        .ThemeColor = xlThemeColorAccent2
        .TintAndShade = 0.399975585192419
    End With
Next sheetNo
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top