+ Reply to Thread
Results 1 to 3 of 3

if-then statement that checks for existence of series 2

  1. #1
    danz98
    Guest

    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. #2
    Jon Peltier
    Guest

    Re: if-then statement that checks for existence of series 2

    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. #3
    danz98
    Guest

    Re: if-then statement that checks for existence of series 2

    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" <[email protected]> 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1