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
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
maybe

VBA Code:
For Each ws In Worksheets
   If ws.Tab.Color = 0 And Not ws.Name = "personalization" Then
      ReDim Preserve strg(count) As String
      strg(count) = ws.Name
      count = count + 1
   End If
Next ws
I'm not seeing the need for the Else that you have there. Nor does that look like a valid procedure name, so is that "air" code?
Also, that only seems to build an array of sheets then does nothing with it as far as fill is concerned. :unsure:
 
Last edited:
Upvote 0
You can also get rid of the 2nd loop like
VBA Code:
Sub NoFill()
Dim ws As Worksheet
Dim strg() As String
Dim count As Integer

ReDim strg(1 To Worksheets.count)
    For Each ws In Worksheets
        If ws.Tab.Color = 0 And Not ws.Name = "personalization" Then
            count = count + 1
            strg(count) = ws.Name
        Else
        End If
    Next ws
    ReDim Preserve strg(1 To count)
    Sheets(strg).Select
End Sub
 
Upvote 0
Solution
Micron & Fluff
thank you very much for your quick reply

it works prefect and 2 more questions would like to ask
first, do you think i use sheet1 instead of the sheet name(personalization) avoid any change as precaution?
second, i have another code from someone here, i would like to run as same as this, run at all sheet exclude sheet1, can i post here?

sorry all for, the subject name should "vba select no fill color tab"
 
Upvote 0
i would like to run as same as this, run at all sheet exclude sheet1, can i post here?
Don't you already have that solution if you modify to use the sheet index number instead of the sheet name?
 
Upvote 0
sorry for any confusing to both Micron and Fluff

i love this code and this is just prefect
but i was thinking to use sheet1 instead of sheet name to avoid any change from others

thank you very much
 
Upvote 0
Opps. You would use
VBA Code:
If ws.Tab.Color = 0 And Not ws.CodeName = "Sheet1" Then
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,825
Members
449,190
Latest member
rscraig11

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