Andrewstupendo
New Member
- Joined
- Jan 29, 2016
- Messages
- 1
Hello All,
I have a question. I would like to add check boxes (activex) under certain conditions. Let's say I have an active worksheet that I am using and I copy and paste additional rows of data into the worksheet. I would like the activex check box private sub worksheet macro to insert additional check boxes next to the new rows of data that I have added. The check boxes are in column K with a linked cell (false) one column offset - column L. I have inserted a sub (non-private) macro that works quite well when adding check boxes to ALL non-blank rows in column A, but it does not add check boxes in an incremental fashion.
here is the code for the non-private sub macro:
Many thanks to davesexcel for this coding.
Is there any way that a private sub worksheet macro can add check boxes while the sheet is open and rows of data are being added in increments?
In other words, if range A136:A142 is not blank, but range L136:L142 IS blank, then fill in K136:K142 with checkboxes as described in the above code. Please see the inserted image of the spreadsheet below.
If this is not possible, I have another solution: Add checkboxes (and the attendant linked cells) to range K23:K300. And then, hide/unhide the check boxes if any cells in range A23:300 are blank/not blank.
I have inserted an image of the spreadsheet for your review.
Many thanks in advance.
Best,
Andrewstupendo
I have a question. I would like to add check boxes (activex) under certain conditions. Let's say I have an active worksheet that I am using and I copy and paste additional rows of data into the worksheet. I would like the activex check box private sub worksheet macro to insert additional check boxes next to the new rows of data that I have added. The check boxes are in column K with a linked cell (false) one column offset - column L. I have inserted a sub (non-private) macro that works quite well when adding check boxes to ALL non-blank rows in column A, but it does not add check boxes in an incremental fashion.
here is the code for the non-private sub macro:
Code:
Sub AddCkBx()
Dim Rws As Long, rng As Range, c As Range, CkBx As OLEObject
Rws = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range(Cells(23, 1), Cells(Rws, 1)).SpecialCells(xlCellTypeConstants, 23)
Application.ScreenUpdating = 0
For Each c In rng.Offset(, 10)
With Sheet1.OLEObjects.Add(ClassType:="Forms.Checkbox.1", _
Top:=c.Top, Left:=c.Left, _
Height:=c.Height, Width:=c.Width)
.Object.Caption = ""
.LinkedCell = c.Offset(0, 1).Address
.Object.Value = 0 'sets checkbox to false
End With
Next c
End Sub
Many thanks to davesexcel for this coding.
Is there any way that a private sub worksheet macro can add check boxes while the sheet is open and rows of data are being added in increments?
In other words, if range A136:A142 is not blank, but range L136:L142 IS blank, then fill in K136:K142 with checkboxes as described in the above code. Please see the inserted image of the spreadsheet below.
If this is not possible, I have another solution: Add checkboxes (and the attendant linked cells) to range K23:K300. And then, hide/unhide the check boxes if any cells in range A23:300 are blank/not blank.
I have inserted an image of the spreadsheet for your review.
Many thanks in advance.
Best,
Andrewstupendo