+ Reply to Thread
Results 1 to 9 of 9

Create chart with 2 series of different types

  1. #1
    Registered User
    Join Date
    05-03-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Create chart with 2 series of different types

    Hi everyone,
    I've been working on a macro that manipulates some data, and have been having trouble with one part of it. Specifically, I have three columns of data - one with percentages, one with simple integers, and one with names. I want to write a macro that:

    1. creates a new sheet (i think i can do this)
    2. creates a new graph that contains 2 series. The data for these series comes from a different sheet (not the activesheet, since that will only contain the graph)
    A. A bar graph with the names (column D) on the x-axis and numbers (column C) on the y-axis
    B. A line graph with the same names (column D) on the x-axis, and the percentages (column A) on a secondary y-axis, with the range from 0 to 1.
    When I do this manually, the wizard tells me that the chart data range is
    Please Login or Register  to view this content.
    I already have a variable that tracks the last row of data, so the "73" in the range above would be my lastrow variable.

    Can someone please help me with this? I've spent 4 or 5 hours trying to figure it out by Googling and trying to record the macro, with no success.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Create chart with 2 series of different types

    Post example workbook with manually created chart so we can see what you are actually after.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-03-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Create chart with 2 series of different types

    Here's a sample workbook. Graph is in the sheet called "graph", and data is in the sheet called "data".
    example.xls


    Any help would be greatly appreciated!
    Last edited by zigggy; 05-04-2011 at 09:53 AM.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Create chart with 2 series of different types

    this should get you started

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-03-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Create chart with 2 series of different types

    That gets me this:
    Screen shot 2011-05-04 at 10.44.14 AM.jpg

    How can I go about making the authors series a bar graph while keeping the cumulative one a line graph? And how would I change the x-axis to reflect author's names in both cases?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Create chart with 2 series of different types

    Did you run that code on the workbook you posted?

    Attached is code in your example with generated output. You can run the code again to create another chart.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-03-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Create chart with 2 series of different types

    Whoops, did it on the wrong document. This works perfectly -- I can't thank you enough!!!

  8. #8
    Registered User
    Join Date
    05-03-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Create chart with 2 series of different types

    One last question: do you know if there's a way to add a single vertical line where the cumulative % = 50%? That is, draw a vertical line at the point where (1) the major gridline that comes from where the secondary axis reads .5 hits (2) the cumulative % curve?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Create chart with 2 series of different types

    You can use formula to calculate the X value for 50%. Not sure how useful it is as it is part way through a Author.

    A xy-scatter series is used to plot the point and x and y error bars are used to draw the line.

    Or maybe you just need to identify the column or line point at which the 50% mark is passed.
    Attached Files Attached Files

+ 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