VBA Click Button to Add New Row below based on and specific text in cell

Wafee_89

New Member
Joined
Jul 26, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
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).

Capture.JPG


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
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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