I have a drilldown list of numbers in cell B2 using data validation. Once user select number in cell B2, it will insert rows below the numbers. The codes I have used:
Sub Insertline()
Dim nRows As Long
Dim range("B2") As Long
range("B2").Select
nRows = range("B2").Value
ActiveCell.Offset(1, 0).Resize(nRows).EntireRow.Insert
End Sub
How do I insert formula in the new rows inserted below B2 since number of rows varies dependent on cell B2? Is there a formula like Do, Loop that can help? Or should I set variable?
Say I want a simple formula like this, I have this:
range("B3").Select
ActiveCell.Formula = range("B2") - (range("B2") - 1)
ActiveCell.Offset(1, 0).Select
But this doesnt work when I have user select different rows in b2.
Please help! Thank you very much!
Sub Insertline()
Dim nRows As Long
Dim range("B2") As Long
range("B2").Select
nRows = range("B2").Value
ActiveCell.Offset(1, 0).Resize(nRows).EntireRow.Insert
End Sub
How do I insert formula in the new rows inserted below B2 since number of rows varies dependent on cell B2? Is there a formula like Do, Loop that can help? Or should I set variable?
Say I want a simple formula like this, I have this:
range("B3").Select
ActiveCell.Formula = range("B2") - (range("B2") - 1)
ActiveCell.Offset(1, 0).Select
But this doesnt work when I have user select different rows in b2.
Please help! Thank you very much!