Nathalia508
New Member
- Joined
- Dec 21, 2021
- Messages
- 3
- Office Version
- 2019
- Platform
- Windows
VBA Code:
Option Explicit
Private Sub CommandButton1_Click()
addNewRow
End Sub
Sub addNewRow()
' Do not insert a row before the first row.
Dim iTopRow As Integer
iTopRow = 1
If (ActiveCell.Row > iTopRow) Then
' Get the active row number.
Dim rowNum As Integer
rowNum = ActiveCell.Row
Rows(rowNum).EntireRow.Insert ' Insert a new row.
End If
End Sub
Option Explicit
Private Sub CommandButton1_Click()
addNewRow
End Sub
Sub addNewRow()
' Do not insert a row before the first row.
Dim iTopRow As Integer
iTopRow = 1
If (ActiveCell.Row > iTopRow) Then
' Get the active row number.
Dim rowNum As Integer
rowNum = ActiveCell.Row
Rows(rowNum).EntireRow.Insert ' Insert a new row.
End If
End Sub