I have about 9 different sheets, but they all will have 4 types of graphs (totals, comparison, bydate, trend). I am writing vba to conditionally show one type of graph on every sheet. For example, if I want to show the totals graphs, I want all of my sheets in the workbook to update. I can already make the graphs go invisible and visible on one sheet, but I would like to do so on all sheets. Here's my code now:
I want to be able to do this on all sheets so I tried something like this:
But no luck. I do not want to manually type all the sheet names into an array because I may add more sheets in the future and don't want to keep changing the code. How can I loop through all sheets and set a graph named "Totals" to invisible? Or can I just set all graphs in the workbook named "Totals" to invisible without looping through the sheets? Thanks!
Sub UpdateGraph() Sheets(".graphManager").ChartObjects("Totals").Visible = False End Sub
Sub UpdateGraph() Dim ws As Worksheet For Each ws In Sheets If ws.Visible Then ws.Select (False) ActiveWorksheet.ChartObjects("Totals").Visible = False Next End Sub