Adding Blank Rows and Columns With VBA Codes

Adding Blank Rows And Columns With VBA Checkbox Control

       
          To insert a checkbox control into Excel worksheet :
☑  On the Developer tab, in the Controls group, Insert is clicked, and Check Box is selected under Form Controls.
  The cell is clicked where you want to insert the checkbox (A1 in this template). 

excel checkbox

          💡 Blank rows and blank columns can be added between the filled rows and columns ,with VBA checkbox controls .
The added rows and columns can be removed with checkbox.

excel vba add row add column

Our codes to add rows:
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
Range("A1").Select
End Sub

Our codes to add cols:
Sub AddCol()
Dim c As Integer
[a1].Select
c = 0
While ActiveCell.Value <> ""
c = c + 2
ActiveSheet.Columns(c).Insert Shift:=xlToRight
ActiveCell.Offset(0, 2).Select
Wend
Range("A1").Select
End Sub


No comments:

Post a Comment