XChecking i a chart variable is empty

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
 
J

JLGWhiz

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.
 
J

JLGWhiz

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.
 
J

Jan Kronsell

Thank you.

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

Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top