![]() |
Altering the range that is plotted by a chart via VBA
Good morning all.
I haven't really done a huge amount on charting, so I'm sure you'll think that these questions are a bit simplistic, but here goes! I plot a chart from a worksheet that contains three columns of data - the X axis contains week numbers, and is in B29:B54. Actual hours are entered in F29:F24 and cumualtive hours in G29:G24. The cumulative formula is of the form: =SUM($F$29:F29) So, each week, in order to plot another week's data, I have to copy this cumulative formula down by one cell, which, considering I have a lot of these reports, is a bit time consuming. If I replace my cumulative formula with something that displays a zero or a label if there is no corresponding weekly actual, the cumulative chart line plummets down to zero, which makes the charts look unprofessional. If I replace it with something that picks up the previous week's cumulative value if there is no corresponding weekly actual, the cumulative chart line goes across at a value equal to the latest cumulative, which also doesn't look too good. So, the question is, how, in this week for example, can I have my chart area as b29:B54 (x-axis);f29:f54 (actuals); g29:f40 (cumulatives), but next week extend my cumulative plot to g29:f41 (i.e. extend it down by one week)? Eventiually, I'd like to etend this idea to plotting a rolling 12 week chart, so to start, it would plot b29:B38 (x-axis);f29:f38 (actuals); g29:f38 (cumulatives) then the next week, b30:B39 (x-axis);f30:f39 (actuals); g30:f39 (cumulatives) and so on, but one thing at a time. If anyone has any good pointers as to how I might achieve some or all of the above, I'd be extremely grateful. Regards & thanks in advance. Pete |
Altering the range that is plotted by a chart via VBA
Got a reply off of the Excel-L mailing list. Had to move the ".ChartType = xlLine" line up higher. Moved it to right after chart creation. I could have sworn I'd gotten errors with that line up higher before. Oh well. Tubbs -- tubbinator ------------------------------------------------------------------------ tubbinator's Profile: http://www.excelforum.com/member.php...o&userid=28239 View this thread: http://www.excelforum.com/showthread...hreadid=477811 |
Altering the range that is plotted by a chart via VBA
You replied to the wrong thread.
Sometimes putting .ChartType up too high will cause an error. If you specify a bubble of stock chart type before specifying enough data to populate that chart type, it will crash. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ tubbinator wrote: Got a reply off of the Excel-L mailing list. Had to move the ".ChartType = xlLine" line up higher. Moved it to right after chart creation. I could have sworn I'd gotten errors with that line up higher before. Oh well. Tubbs |
Altering the range that is plotted by a chart via VBA
Thanks to all who replied.
I eventually achieved what I wanted by plotting the chart against named ranges, and using VBA to redefine the ranges to which those named applied. The charts automtically updated based on the redefined ranges. I shouldn't have been so lazy! Regards & have a good weekend. Pete "Peter Rooney" wrote: Good morning all. I haven't really done a huge amount on charting, so I'm sure you'll think that these questions are a bit simplistic, but here goes! I plot a chart from a worksheet that contains three columns of data - the X axis contains week numbers, and is in B29:B54. Actual hours are entered in F29:F24 and cumualtive hours in G29:G24. The cumulative formula is of the form: =SUM($F$29:F29) So, each week, in order to plot another week's data, I have to copy this cumulative formula down by one cell, which, considering I have a lot of these reports, is a bit time consuming. If I replace my cumulative formula with something that displays a zero or a label if there is no corresponding weekly actual, the cumulative chart line plummets down to zero, which makes the charts look unprofessional. If I replace it with something that picks up the previous week's cumulative value if there is no corresponding weekly actual, the cumulative chart line goes across at a value equal to the latest cumulative, which also doesn't look too good. So, the question is, how, in this week for example, can I have my chart area as b29:B54 (x-axis);f29:f54 (actuals); g29:f40 (cumulatives), but next week extend my cumulative plot to g29:f41 (i.e. extend it down by one week)? Eventiually, I'd like to etend this idea to plotting a rolling 12 week chart, so to start, it would plot b29:B38 (x-axis);f29:f38 (actuals); g29:f38 (cumulatives) then the next week, b30:B39 (x-axis);f30:f39 (actuals); g30:f39 (cumulatives) and so on, but one thing at a time. If anyone has any good pointers as to how I might achieve some or all of the above, I'd be extremely grateful. Regards & thanks in advance. Pete |
All times are GMT +1. The time now is 04:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com