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.
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.
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.