Inserting formula in range

0 Agios

Well-known Member
Joined
Feb 22, 2004
Messages
570
Office Version
  1. 365
I am trying to insert the same formula in a range where it will copy the cell above and add 1
The starting cell will start with January and the next cell should automatically say February

this is the form
ComboBox2.AddItem "1 Year"
ComboBox2.AddItem "2 Years"
ComboBox2.AddItem "3 Years"
ComboBox2.AddItem "4 Years"
ComboBox2.AddItem "5 Years"
ComboBox2.AddItem "6 Years"
ComboBox2.AddItem "7 Years"
ComboBox2.AddItem "8 Years"
ComboBox2.AddItem "9 Years"
ComboBox2.AddItem "10 Years"

and this is in a button in same form

Select Case ComboBox2
Case "1 Year"
Range("D11:D21").FormulaR1C1 = "=R[-1]C+1"
Case "2 Years"
Range("D11:D33").FormulaR1C1 = "=R[-1]C+1"
Case "3 Years"
Range("D11:D45").FormulaR1C1 = "=R[-1]C+1"
Case Else

End Select
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Is this what you want to do?

VBA Code:
N = 12 * Val(Left(ComboBox2.Text, 2))

With Range("D10")
    .Formula2 = "=EDATE(DATE(2023,1,1),SEQUENCE(" & N & ",,0))"
    .Resize(N).NumberFormat = "MMM"
End With
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,988
Members
449,093
Latest member
Mr Hughes

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