Excel Add Blank Rows With Checkbox Or Button

Excel VBA Add Blank Rows


            New blank rows can be added under each row with checkbox and button controls . Blank rows can be deleted with the deleting button.
The new rows are added as blank rows under each rows.


 The used codes to add - remove rows with checkbox :
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Call Addrow
Else
Call Clr
End If
End Sub

Sub Addrow()
Dim a As Byte
Dim c As Integer
[A1].Select
a = 2
c = 0
While ActiveCell.Value <> ""
c = c + 2
ActiveSheet.Rows(c).Insert Shift:=xlDown
ActiveCell.Offset(a, 0).Select
Wend
End Sub

Sub Clr()
On Error Resume Next
Range("A2").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

Excel VBA Add Row

 The used codes to add - remove rows with buttons :
Private Sub CommandButton1_Click()
Call Addrow
End Sub

Private Sub CommandButton2_Click()
Call Clr
End Sub


excel vba add blank rows

No comments:

Post a Comment