XChecking i a chart variable is empty

  • Thread starter Thread starter Jan Kronsell
  • Start date Start date
J

Jan Kronsell

I have the following lines:

Dim chtDiagra As Chart
Set chtDiagra = ActiveChart

How do I check if chtDiagra is empty. That will happne if no chart is
selected, when the code is run.

Jan
 
Put your relevant code inside an If...Then statement:

If Not chtDiagra Is Nothing Then
'code to do something here
End If

The code will only execute if chtDiagra has value, otherwise it goes on to
the next executable line.
 
The syntax is not correct. I don't work with charts in VBA very often, so I
would have to look up the syntax for getting to the chart object via code,
but the priciple is to check for the object type that is selected to make
sure it is a chart of some kind. Check in the charting news group, someone
there probably has it handy.
 
Thank you.

I actually ended up making an On error routine grabbing the returned error ,
if a chart is not selected.

Jan
 
Back
Top