View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
PCTurbo PCTurbo is offline
external usenet poster
 
Posts: 1
Default 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