Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nothing Keyword Destories Objects rather than just resetting the variable to an empty variable Ronald R. Dodge, Jr.[_2_] Excel Programming 15 December 15th 08 09:19 PM
Chart empty with new data in the dynamic range chart. Feejo Excel Discussion (Misc queries) 16 January 3rd 08 10:03 PM
array variable is empty? mark Excel Programming 4 October 7th 06 11:57 PM
If Range Variable isn't Empty achidsey Excel Programming 3 October 19th 05 07:15 PM
empty variable range S1 Excel Discussion (Misc queries) 5 January 28th 05 02:33 PM


All times are GMT +1. The time now is 09:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"