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).
💡 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.
The added rows and columns can be removed with checkbox.
Our VBA codes that allow us to add blank rows under filled 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
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 VBA codes that allow us to add new columns next to the columns :
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
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