ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   No chart if there is no data (https://www.excelbanter.com/excel-discussion-misc-queries/115976-no-chart-if-there-no-data.html)

PCTurbo

No chart if there is no data
 
Hi,
I have an spreadsheet template that is being used to create multiple
reports. This template has multiple charts. In some of the reports
there is no data to feed the report, but it still shows the chart
(empty of course).
I would like for this not to show if there is no data. there are over a
houndred reports that are being generated which is why it is very
tedious to remove each empty chart by hand.

I have tried some VBA scripts but was not successfull. I have found a
similar topic in this newsgroup but the solution did not work for me.
Any suggestions??

Here is a link to that topic
http://groups.google.nl/group/micros...2207df658410f0


Here is the code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cht As ChartObject
Dim strSeries As String
Dim blnSeeChart As Boolean

On Error GoTo BLANK_CHART
For Each Cht In ActiveSheet.ChartObjects
blnSeeChart = True
strSeries = Cht.Chart.SeriesCollection(1).Formula
Cht.Visible = blnSeeChart
Next Cht

Exit Sub

BLANK_CHART:
blnSeeChart = False
Resume Next

End Sub



All times are GMT +1. The time now is 12:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com