+ Reply to Thread
Results 1 to 2 of 2

Primary/Secondary Axis series count

  1. #1
    Registered User
    Join Date
    07-28-2005
    Posts
    1

    Question Primary/Secondary Axis series count

    Hi, I have a VBA function like so:

    Please Login or Register  to view this content.
    Sometimes I add a series to the Primary Y axis and other times to the Secondary.

    How can I determine how many series are on the Primary and how many on the secondary?????

    Application could begin with an unknown number of series already present on each axis so can't use a counter.

    Cheers,
    Rayden

  2. #2
    Andy Pope
    Guest

    Re: Primary/Secondary Axis series count

    Hi,

    Here is a code snippet that will display count of series on primary and
    secondary axis.

    Sub x()
    Dim intCountP As Integer
    Dim intCountS As Integer
    Dim objSeries As Series

    With ActiveChart
    For Each objSeries In .SeriesCollection
    If objSeries.AxisGroup = xlPrimary Then
    intCountP = intCountP + 1
    Else
    intCountS = intCountS + 1
    End If
    Next
    End With
    MsgBox "Primary axis has " & intCountP & " Series" & vbLf & _
    "Secondary axis has " & intCountS & " Series"
    End Sub

    Cheers
    Andy

    raydenl wrote:
    > Hi, I have a VBA function like so:
    >
    >
    > Code:
    > --------------------
    >
    > Private Sub AddSeries(ByVal strName As String, ByVal rngValues As Range, ByVal rngValuesX As Range, ByVal xlAxis As XlAxisGroup)
    > With Charts("Chart").SeriesCollection.NewSeries
    > .AxisGroup = xlAxis
    >
    > .ChartType = xlLine
    > .Name = strName
    > .Values = rngValues
    > .XValues = rngValuesX
    > End With
    > End Sub
    >
    > --------------------
    >
    >
    > Sometimes I add a series to the Primary Y axis and other times to the
    > Secondary.
    >
    > How can I determine how many series are on the Primary and how many on
    > the secondary?????
    >
    > Application could begin with an unknown number of series already
    > present on each axis so can't use a counter.
    >
    > Cheers,
    > Rayden
    >
    >


    --

    Andy Pope, Microsoft MVP - Excel
    http://www.andypope.info

+ 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