Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9137491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:06:35+00:00 2026-06-17T09:06:35+00:00

I have a line chart to which I’m attempting to add, via VBA, a

  • 0

I have a line chart to which I’m attempting to add, via VBA, a horizontal line at a given Y value. I’m following this guide, which suggests adding a line to an existing chart and then changing its type to scatter, which causes Excel to put the series on the secondary X axis automatically. It can then be formatted further.

My problem is that when doing this with VBA I don’t understand how to switch a line onto the secondary X axis. By default all new lines will go on the primary X axis.

For example, suppose chrt is a Chart object:

' Enable secondary X axis (I think)
chrt.HasAxis(XlAxisType.xlCategory, XlAxisGroup.xlSecondary) = True

Dim se As Series
Set se = chrt.SeriesCollection.NewSeries
se.ChartType = xlXYScatterLinesNoMarkers

' Add a line at Y = 0
se.xValues = Array(0, 1)
se.values = Array(0, 0)

Now, how to get se onto the secondary X axis?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:06:36+00:00Added an answer on June 17, 2026 at 9:06 am

    I followed this link for Excel 2003 and recorded a macro. Please note that for Excel 2007 charts have such a unfortunate cases with recording macros. But you get lucky in Excel 2010 again. So watch out for your version if you are going to do it based on a macro and then copy the code…

    Change sheet and chart name according to yours.

    With Sheets(3).ChartObjects("Chart 1")
         .SeriesCollection(2).AxisGroup = xlSecondary
         .HasAxis(xlCategory, xlPrimary) = True
         .HasAxis(xlCategory, xlSecondary) = True
         .HasAxis(xlValue, xlPrimary) = True
         .HasAxis(xlValue, xlSecondary) = True
         .Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
         .Axes(xlCategory, xlSecondary).CategoryType = xlAutomatic
      End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this json which i need to work with amCharts line chart, var
I have my google line chart which looks something like this: 10| . |
I have made a simple Line Chart: Which is showing 4 grid-lines at points
For example we have this line chart at Google Code API there is a
I have a simple JSF line chart that uses PrimeFaces (via jqPlot) library: <p:lineChart
Ext-js Chart, I have a line graph, and I wish to add a single
I have line chart which has values : flock_age = X-axis = 16, 17,
I have a JFree XY Line chart which always starts at x = 0.
I have an excel line chart which its x axis holds time values and
I have a highstock chart which hosts a stacked column + a spline line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.