vba select more fill color tab

kelvin_9

Active Member
Joined
Mar 6, 2015
Messages
444
Office Version
  1. 2019
Hi All,
I need some guidance on below code that how can I run this perfectly exclude sheet1(custom name: personalization)

Thank you very much

VBA Code:
Sub No Fill()
Dim ws As Worksheet
Dim strg() As String
Dim count As Integer
count = 1
 
    For Each ws In Worksheets
        If ws.Tab.Color = 0 Then
            ReDim Preserve strg(count) As String
            strg(count) = ws.Name
            count = count + 1
        Else
        End If
    Next ws
    
    Sheets(strg(1)).Select
    For i = 2 To UBound(strg)
        Sheets(strg(i)).Select False
    Next i
 
End Sub
 
or
If ws.Tab.Color = 0 And Not Sheets(ws.Name).Index = 1 Then ?
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
thank you very much to Fluff
thank you very much to Micron

both are wonderful and do my needs
 
Upvote 0
One word of warning. If someone changes the order of the sheets then this could fail Not Sheets(ws.Name).Index = 1 Then You would be better off using the codename.
 
Upvote 0
10-4
I thought the index property was based on the order that a sheet was added to the workbook sheets collection and wouldn't change based on its position in the tab order. Perhaps that is not the case. I learned of the codename property today - thanks.
 
Upvote 0
I wish it was that simple. However the Index is the position of the sheet within the workbook, so if you move sheets around their index will change.
 
Upvote 0

Forum statistics

Threads
1,215,401
Messages
6,124,705
Members
449,182
Latest member
mrlanc20

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