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.
 

Gregory72

New Member
Joined
Jun 25, 2014
Messages
12
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
 

Forum statistics

Threads
1,081,690
Messages
5,360,614
Members
400,592
Latest member
badgergurl

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top