Referencing an array of cells to toggle sheet visibility based on each cell's content

Gregory72

New Member
Joined
Jun 25, 2014
Messages
12
Hi,

I'm trying to writea code that doesn't require stepping into vba to effect the outcome of themacro.

Currently, I have acode that toggles the visibility of an array of sheets if the target cellmatches certain conditions (blue or dark blue fill). This code works great.However, I want to replace the sheet array in vba with a cell array in theworkbook. This cell array would contain the values 01, 02, 03, ... , 11 in thecode below. Ideally the macro would simply check the values of these cellsevery time it is run to know what sheets it needs to show/hide.

Current code (partof it):

Dim sh
For Each sh InSheets(Array("01", "02", "03", "04","05", "06", "07", "08", "09","10", "11"))
IfTarget.Interior.Color = b Then
sh.Visible = NotVisible
ElseIfTarget.Interior.Color = Db Then
sh.Visible = Visible
End If
Next


Thanks in advancefor any help.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
The spacing got messed up somehow. Sorry for the annoying read. Here's fixed code

Dim sh
For Each sh In Sheets(Array("01", "02", "03", "04", "05", "06", "07", "08"))
If Target.Interior.Color = b Then
sh.Visible = Not Visible
ElseIf Target.Interior.Color = Db Then
sh.Visible = Visible
End If
Next
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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