+ Reply to Thread
Results 1 to 6 of 6

Thread: Secondary Axis line chart formatting

  1. #1
    Registered User
    Join Date
    12-01-2008
    Location
    USA
    Posts
    5

    Secondary Axis line chart formatting

    I have a bunch of charts that I need to plot voltage and current measurments on primay and secondary axis respectivly.

    Is there anyway to do this when I create the chart? Each chart will have four different series on the primary axis and eight on the secondary.

    The problem I have is when creating the chart everything gets put on the primary axis. when I select a data set and place it on the secondary axis Excel automatically adds markers to the line. Now I have to go it and remove the markers.

    This just creates more work for me.

    Is there any way to place a data set on the secondary axis without Excel adding markers or doing anything else I did not ask for?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,349
    what excel are you using?

    In xl2003 I just create a multiple line chart with mixed marker and non marker lines. Moving axis did not alter the line style, colour or marker.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    12-01-2008
    Location
    USA
    Posts
    5
    I am using Excel 2003-SP3

    I have included an example. Chart 1 is the defalut line chart output Chart 2 is the same defaults as Chart 1 but I placed the second series (Line 2) on a secondary axis.

    Notice that Excel changed the line style to a line with markers.

    Now on a chart with only two series its no bit deal, but larger charts with more data points in each series that are close in value this becomes a real P.I.A. to go back and reformat every line that Excel changes.
    Attached Files Attached Files

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,349
    Well what do know. Never notied that before.

    Here is some code to sort out the lines on the secondary axis

    Sub X()
    
        Dim objSeries As Series
        
        With ActiveChart
            For Each objSeries In .SeriesCollection
                If objSeries.AxisGroup = xlSecondary Then
                    objSeries.MarkerStyle = xlMarkerStyleNone
                End If
            Next
        End With
        
    End Sub
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    12-01-2008
    Location
    USA
    Posts
    5
    Thanks!

    Now how do I use that code?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,349
    You need to add it to a module. Either in a new workbook or the one with the charts.
    Go to VBE (ALT+F11)
    Insert Module
    Paste code.

    To use select a chart and then run code.

    If you have many charts then you would need to add some more code to loop through all the charts and or chartobjects. There are examples of this on the forum but if you get stuck post back.
    Cheers
    Andy
    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.2.0