x
Solved

# Cashflow Graphic

Posted on 2013-11-09
Medium Priority
266 Views
EE Pros,

I have a "very cool" Cashflow Graph that calculates several financial elements.  Presently it's simply a 36 month (fixed) analysis.  I would like to add one feature to it.  When you select the Timeframe, I'd like the graphic to automatically size and calculate based on the selected Timeframe  up to 60 months (e.g. 12 months, 18 months, 36 months, 60 months).

That's it!

B.
Cashflow-Chart.xlsm
0
Question by:Bright01
• 2

LVL 6

Expert Comment

ID: 39635614
The follow code block may get you going in the right direction...
``````Public Sub RefreshChart()
Dim Period As Integer
Dim ws As Worksheet

Dim rSet1 As Range
Dim rSet2 As Range
Dim rSet3 As Range
Dim rSet0 As Range

Period = Range("B3").Value
Set ws = ActiveSheet

Set rSet1 = Range("F24").Resize(1, Period + 1)
Set rSet2 = Range("F37").Resize(1, Period + 1)
Set rSet3 = Range("F38").Resize(1, Period + 1)
Set rSet0 = Union(rSet1, rSet2, rSet3)

ws.Shapes("Chart 1").Select
ActiveChart.SetSourceData rSet0

End Sub
``````

It will look at cell B3 and adjust the adjust the data set based on the number of months.  It is assuming that the chart is "Chart 1" -- this could be easily adjusted to a more meaningfull name.
Tom

Tom
0

Author Comment

ID: 39636211
Tom,

I put the code in the Spreadsheet and it didn't work.   It is Chart 1, however there is a Chart 2 that also overlays Chart 1 which produces the BEP (Break Even Point) line.  I also disabled "the links" and connected up the right numbers so you can see what changes when you change the Costs/Benefits (C25 - E26).  Can you take a look at the WS and see what I'm doing wrong?

B.
Cashflow-Chartv2.xlsm
0

LVL 81

Accepted Solution

byundt earned 2000 total points
ID: 39636443
I don't think that you need VBA to accomplish your chart. Nor do you need that severely annoying second chart overlaid on top of the first. You will need to extend your formulas in rows 24:38 out to column BN if you want to allow up to 5 years.

You can use dynamic named ranges for Months, the red bars and the green bars. I created these using OFFSET formulas like this:
=OFFSET(\$F\$37,0,0,1,\$B\$3)

I then used the dynamic named ranges in the chart as a series source with a formula like this:
='Name of workbook.xlsm'!Months

To get the vertical bar, I added a two point series. The first point was (BEP month + 1, - investment). The second point was (BEP month + 1, green cash flow at end of term). I put these formulas in cells E50:F51, then added them as an additional series. Having done this, I changed the chart to a combo type, with the BEP series on a scatter chart. Adding 1 month to the BEP month got the vertical bar centered in approximately the right place.
Cashflow-ChartvQ28289807.xlsm
0

Author Closing Comment

ID: 39637044
Outstanding!  That's just what I was looking for!  Simple, extended solution.  Excellent work...."Thank you!".

B.
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.