VBA Creating my Waterfall Code

Chassmin

New Member
Joined
Jul 11, 2017
Messages
6
Hello everyone!

I am new at this website. I am currently working for a bank and I have to do loads of Waterfalls so I tought that I could automatize the process.

Based on this website, http://www.contextures.com/excelwaterfallchart.html , I started recording my moves with VBA to get to the same result.

But I encountered two main issues:
1) The columns I tried to insert beween the numbers (5000; -503; ... 2475) and the labels (Start; Jan ... Dec) are not insterted in between those two columns but at the right of the numbers.
2) the Downs and Ups are not calculated and when I click in the cell I find these formulas =-MIN(#REF!;0) and =MAX(#REF!;0) instead of the formulas I wanted (given in the website above).


Code:
Sub Waterfall()
'
' Waterfall Macro
'
'
    Columns("E:E").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("E3").Select
    ActiveCell.FormulaR1C1 = "Base"
    Range("F3").Select
    ActiveCell.FormulaR1C1 = "End"
    Range("G3").Select
    ActiveCell.FormulaR1C1 = "Down"
    Range("H3").Select
    ActiveCell.FormulaR1C1 = "Up"
    Range("I3").Select
    ActiveCell.FormulaR1C1 = "Start"
    Range("J3").Select
    ActiveCell.FormulaR1C1 = "Net Cash Flow"
    Range("E4").Select
    ActiveCell.FormulaR1C1 = "2000"
    Range("E19").Select
    ActiveCell.FormulaR1C1 = "2000"
    Range("I5").Select
    ActiveCell.FormulaR1C1 = "5000"
    Range("H6").Select
    ActiveCell.FormulaR1C1 = "=MAX(RC[2],0)"
    Range("G6").Select
    ActiveCell.FormulaR1C1 = "=-MIN(RC[3],0)"
    Range("J18").Select
    Selection.Cut
    Range("F18").Select
    ActiveSheet.Paste
    Range("E6").Select
    ActiveCell.FormulaR1C1 = "=SUM(R[-1]C,R[-1]C[3]:R[-1]C[4])-RC[2]"
    Range("E6").Select
    Selection.AutoFill Destination:=Range("E6:E17"), Type:=xlFillDefault
    Range("E6:E17").Select
    Range("G6").Select
    Selection.AutoFill Destination:=Range("G6:G17"), Type:=xlFillDefault
    Range("G6:G17").Select
    Range("H6").Select
    Selection.AutoFill Destination:=Range("H6:H17"), Type:=xlFillDefault
    Range("H6:H17").Select
End Sub


Thank you so much I mean it :)

Jasmin
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top