Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
danz98
 
Posts: n/a
Default if-then statement that checks for existence of series 2

This has been posted to excel.programming



I would like to code an if-then or Case statement that does something like this:



If ActiveChart.SeriesCollection(2) doesn’t exist, Then



ActiveChart.SeriesCollection.NewSeries.Add

ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R1C9:R2C9"

ActiveChart.SeriesCollection(2).Values = "=Sheet1!R1C10:R2C10"



Else



ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R1C9:R2C9"

ActiveChart.SeriesCollection(2).Values = "=Sheet1!R1C10:R2C10"



The only difference is the NewSeries.Add. What do I substitute for doesn’t exist? 0 (zero) or False?



Danz98



  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

If ActiveChart.SeriesCollection.Count = 1 Then
ActiveChart.SeriesCollection.NewSeries
End If

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

danz98 wrote:



This has been posted to excel.programming



I would like to code an if-then or Case statement that does something
like this:



If ActiveChart.SeriesCollection(2) doesn’t exist, Then



ActiveChart.SeriesCollection.NewSeries.Add

ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R1C9:R2C9"

ActiveChart.SeriesCollection(2).Values = "=Sheet1!R1C10:R2C10"



Else



ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R1C9:R2C9"

ActiveChart.SeriesCollection(2).Values = "=Sheet1!R1C10:R2C10"



The only difference is the NewSeries.Add. What do I substitute for
doesn’t exist? 0 (zero) or False?



Danz98



  #3   Report Post  
danz98
 
Posts: n/a
Default

This code was suggested in the excel.programming newsgroup:

ActiveChart.HasAxis(xlValue) = True '<-- add this line
With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScale = 3
.MinorUnit = 0.1
.MajorUnit = 0.5
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.HasAxis(xlValue) = False '<-- add this line

by: okaizawa

It worked. It's frustrating that all the different recorded macros did not suggest the code.

"danz98" wrote in message news:2YbMe.4317$%K4.2387@trnddc09...
This has been posted to excel.programming



I would like to code an if-then or Case statement that does something like this:



If ActiveChart.SeriesCollection(2) doesn’t exist, Then



ActiveChart.SeriesCollection.NewSeries.Add

ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R1C9:R2C9"

ActiveChart.SeriesCollection(2).Values = "=Sheet1!R1C10:R2C10"



Else



ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R1C9:R2C9"

ActiveChart.SeriesCollection(2).Values = "=Sheet1!R1C10:R2C10"



The only difference is the NewSeries.Add. What do I substitute for doesn’t exist? 0 (zero) or False?



Danz98



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
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
How to calculate a sum as one outcome of an IF statement barb in NC Excel Worksheet Functions 2 March 31st 05 08:01 PM
What statement to use? Paul Excel Worksheet Functions 6 February 13th 05 05:23 PM
How do I fix a circular reference in a financial statement? drjayhawk25 Excel Discussion (Misc queries) 0 February 7th 05 05:19 PM
7+ nested if statement? Turi Excel Worksheet Functions 3 December 20th 04 07:55 PM


All times are GMT +1. The time now is 12:34 AM.

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

About Us

"It's about Microsoft Excel"