Hi can anyone help me create a macro that selects all worksheet tabs of a particular color. For instance, if i am selecting a worksheet that the tab is colored red, what is the vba code to select all red tabs in the workbook?
Hi can anyone help me create a macro that selects all worksheet tabs of a particular color. For instance, if i am selecting a worksheet that the tab is colored red, what is the vba code to select all red tabs in the workbook?
just try...
andSub Button1_Click() Dim ws As Worksheet For Each ws In Worksheets If ws.Tab.Color = vbRed Then ws.Visible = xlSheetHidden Next ws End Sub
Sub Button2_Click() Dim ws As Worksheet For Each ws In Worksheets If ws.Tab.Color = vbRed Then ws.Visible = xlSheetVisible Next ws End Sub
Regards, John55
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
...enjoy -funny parrots-
replace the number with your own color number
You can find out about the tab color by usingSub Macro2() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets If ws.Tab.Color = 192 Then ws.Select (False) End If Next ws End Sub
msgbox activesheet.tab.color
What if I want the macro to be written so that if I click on a tab of any color all tabs of that color.in the workbook are selected. Thx for ur help:D
In that case put this in your workbook module. I use a conditional check box to turn on/off macro. In my case, if worksheet macro on and off range A1 = True then macro is active, if A1= False then macro is inactive.
Anyone know why I am having issue with checkbox active x control? If I use checkbox as a conditional check if won't let me go into Design mode unless I select other tab first.
Private Sub Workbook_SheetActivate(ByVal Sh As Object) If Worksheets("Turn on off macro").Cells(1, 1) = True Then Call Test End If End Sub Sub Test() Dim Ws As Worksheet For Each Ws In ThisWorkbook.Worksheets If Ws.Tab.Color = ActiveSheet.Tab.Color Then Ws.Select (False) End If Next Ws End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks