ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   XChecking i a chart variable is empty (https://www.excelbanter.com/excel-programming/432407-xchecking-i-chart-variable-empty.html)

Jan Kronsell

XChecking i a chart variable is empty
 
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



JLGWhiz[_2_]

XChecking i a chart variable is empty
 
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.

"Jan Kronsell" wrote in message
...
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




Jan Kronsell

XChecking i a chart variable is empty
 
Thank you.

It tried that, but used IsEmpty, not IsNothing :-)

Jan

JLGWhiz wrote:
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.

"Jan Kronsell" wrote in message
...
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




JLGWhiz[_2_]

XChecking i a chart variable is empty
 
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.


"Jan Kronsell" wrote in message
...
Thank you.

It tried that, but used IsEmpty, not IsNothing :-)

Jan

JLGWhiz wrote:
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.

"Jan Kronsell" wrote in message
...
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






Jan Kronsell

XChecking i a chart variable is empty
 
Thank you.

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

Jan

JLGWhiz wrote:
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.


"Jan Kronsell" wrote in message
...
Thank you.

It tried that, but used IsEmpty, not IsNothing :-)

Jan

JLGWhiz wrote:
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.

"Jan Kronsell" wrote in message
...
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





All times are GMT +1. The time now is 04:43 AM.

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