Excel VBA Add Blank Rows
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() ' The main procedure that allows us to add blank rows under filled rows
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
If CheckBox1.Value = True Then
Call Addrow
Else
Call Clr
End If
End Sub
Sub Addrow() ' The main procedure that allows us to add blank rows under filled rows
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
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
Call Addrow
End Sub
Private Sub CommandButton2_Click()
Call Clr
End Sub
No comments:
Post a Comment