VBA set charts on multiple sheets invisible Excel -


i have 9 different sheets, have 4 types of graphs (totals, comparison, bydate, trend). writing vba conditionally show 1 type of graph on every sheet. example, if want show totals graphs, want of sheets in workbook update. can make graphs go invisible , visible on 1 sheet, on sheets. here's code now:

sub updategraph()  sheets(".graphmanager").chartobjects("totals").visible = false end sub 

i want able on sheets tried this:

sub updategraph()  dim ws worksheet     each ws in sheets        if ws.visible ws.select (false)          activeworksheet.chartobjects("totals").visible = false     next end sub 

but no luck. not want manually type sheet names array because may add more sheets in future , don't want keep changing code. how can loop through sheets , set graph named "totals" invisible? or can set graphs in workbook named "totals" invisible without looping through sheets? thanks!

you pass in parameter determines graph should visible each time. @ time selecting graph type, can call function once, pass in selected graph type, , turn graph on , others off, across sheets.

sub updategraph(graphtype string)  dim ws worksheet     each ws in sheets         each co in ws.chartobjects             '''turn off charts on sheet first'''             ws.chartobjects(co.name).visible = false         next         '''turn on 1 chart type want'''         ws.chartobjects(graphtype).visible = true     next end sub 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -