+ Reply to Thread
Results 1 to 9 of 9

Graphing dynamic range with vba

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Graphing dynamic range with vba

    Hi!
    I am trying to graph a dynamic range using VBA, but don't know how to get all of the data I need on to one chart.
    I came very close, please see the attached sheet. I've gotten thus far thanks to John Peltier's blog.

    The data on the sheet looks like this:
    .......................Apr2 Apr 14 Apr 21
    Physical percentage 90 92 93
    Economic percentage 91 93 94

    I can get the numbers onto the graph, but I cant get the dates to be displayed on the x-axis of the graph through VBA.
    If I take the boxes around the data and drag them over the dates, they appear on the graph.

    What can I do to make the dates appear on the x-axis of the chart?
    Its almost done. Thank you for the help!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Graphing dynamic range with vba

    I couldn't figure out which dates you wanted to chart. So I just charted all the dates that had data (E5:M7) in your example workbook. The dates should appear on the x axis.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Graphing dynamic range with vba

    Thank you for the reply. There is one more thing I need to mention.
    The ranges are dynamic and you can see that when you go to Name Manager and see what the named ranges are.
    There is a lot going on in terms the Offset function. When you change the number in the top leftmost cell in the sheet, the number of cells in the range is selected accordingly.
    I cannot simply use the correction above because it's is very important that I keep that dynamic functionality.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Graphing dynamic range with vba

    Try this...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Graphing dynamic range with vba

    Here are the instructions I used- http://peltiertech.com/Excel/Charts/DynamicLast12.html

  6. #6
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Graphing dynamic range with vba

    Aaand it works as intended. Thank you very much for the help!

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Graphing dynamic range with vba

    You're welcome.

    This could work as well without the dynamic named ranges. The code could calculate your dynamic range.
    .SetSourceData Source:=[E5].Resize(3, [A1].value), PlotBy:=xlRows

  8. #8
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Graphing dynamic range with vba

    Saved me a solid 2 days of work wit that last bit..
    Thanks a bunch! =)

  9. #9
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Graphing dynamic range with vba

    I was about to make 3 ranges to display each chart according to the instructions I posted above. For a total of about 50 charts.
    Glad to see it wasn't necessary.
    I will read up on that Resize function you were using.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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