Adding a Button to create new Column

KlayColgrove

New Member
Joined
Oct 19, 2018
Messages
12
I am trying to add more columns to a worksheet that each column indicated a different year. I have years 1 through 5, but I want to be able to click a button and add more years continuing to as many as I want. Years 1 through 5 have formulas and I want to be able to bring those over as well. The code I have right now seems to be putting the formulas into separate columns and not continuing onto the same column.
Code:
Sub Add_Year()
    
    Dim Formulas(1 To 3) As Variant
   
    With ThisWorkbook.Worksheets("Project Cash Flow")
        Formulas(1) = "=I9-I10"
        Formulas(2) = "=I11+I28"
        Formulas(3) = "=(I9-I10)*$E$13"
        .Range("O11:O13").Formula = Formulas
        .Range("O:O").NumberFormat = "General"
    End With
    
End Sub

There are a lot more formulas, but I have just been working with 3 to try to figure it out. I also want to be able to delete a year, just in case I accidently click it too many times and have a separate button to go back instead of just high lighting and deleting.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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