Utradeshow
Well-known Member
- Joined
- Apr 26, 2004
- Messages
- 802
- Office Version
- 365
Hi All,
I have this code that adds rows based on the value of cell A2. I need two things. I would like the code to run after the value is entered in cell A2 vs having to press a add button. and also would like it to add rows starting from row 11 down? Is that possible?
I have this code that adds rows based on the value of cell A2. I need two things. I would like the code to run after the value is entered in cell A2 vs having to press a add button. and also would like it to add rows starting from row 11 down? Is that possible?
VBA Code:
Sub InsertRow()
Dim ws As Worksheet
Dim NBOFROWS As Range
Set ws = ThisWorkbook.ActiveSheet
With ws
Set NBOFROWS = .Range("A2")
ActiveCell.EntireRow.Offset(1).Resize(NBOFROWS.Value).Insert shift:=xlDown
End With
End Sub