Hi, i have prepared VBA to add button to add new cell below by maintaining format and formula from cell above.
However, the current VBA just add new row when my cursor selected a cell. What i need is the vba that only work for cell that contain certain text (and the lowest row that contain same text).
Example, i want to add row only to the cell that contain word "Insert" which located at lowest row. Sample photo, if i put select cell B9, and add 2 row, only it happen like the photo. Btw, i put formula to Column A (if column E contain number, column A will appear word insert, else word Delete will appear).
THIS IS MY CURRENT VBA CODE
Sub RectangleRoundedCorners1_Click()
Dim howMany As Long
howMany = InputBox("How many rows?")
Dim i As Long
For i = 1 To howMany
With ActiveCell.EntireRow
.Copy
.Offset(1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
On Error Resume Next
.Offset(1).SpecialCells(xlCellTypeConstants).Value = ""
Application.CutCopyMode = False
On Error GoTo 0
End With
Next
End Sub
However, the current VBA just add new row when my cursor selected a cell. What i need is the vba that only work for cell that contain certain text (and the lowest row that contain same text).
Example, i want to add row only to the cell that contain word "Insert" which located at lowest row. Sample photo, if i put select cell B9, and add 2 row, only it happen like the photo. Btw, i put formula to Column A (if column E contain number, column A will appear word insert, else word Delete will appear).
THIS IS MY CURRENT VBA CODE
Sub RectangleRoundedCorners1_Click()
Dim howMany As Long
howMany = InputBox("How many rows?")
Dim i As Long
For i = 1 To howMany
With ActiveCell.EntireRow
.Copy
.Offset(1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
On Error Resume Next
.Offset(1).SpecialCells(xlCellTypeConstants).Value = ""
Application.CutCopyMode = False
On Error GoTo 0
End With
Next
End Sub