I have a sheet with a >20K rows - in lets say column C I currently have the either True/False - this tells me if a row should be included in an action. But I would like the cell to contain a CheckBox - However the only way is by inserting a Control - hmmm - so below is my test code for inserting the checkboxes - it seems to work.
BUT will 20K checkbox controls make my sheet "unstable" - memory problems - freeze up and so on - any comments would me much appreciated.
I use 'option compare text' - so it dont matter if TRUE/FALSE is in upper/lower case.
BUT will 20K checkbox controls make my sheet "unstable" - memory problems - freeze up and so on - any comments would me much appreciated.
I use 'option compare text' - so it dont matter if TRUE/FALSE is in upper/lower case.
Code:
Public Sub AddCheckboxes(ByVal ColManipulate As String, ByVal FirstCRow As Long, ByVal LastCRow As Long, ByVal ChkBoxCaption As String)
'ColManipulate ----- This is the column that the checkbox should reside in
'FirstCRow ---- First Row to have checkbox added
'LastCRow ---- Last Row to have checkbox added
'ChkBoxCaption ---- If you want caption - but cell is linked
Dim myBox As CheckBox
Dim myCell As Range
Dim CellRange As String
CellRange = ColManipulate & FirstCRow & ":" & ColManipulate & LastCRow
With ActiveSheet
For Each myCell In .Range(CellRange).Cells
With myCell
Astr = .Text
Set myBox = .Parent.CheckBoxes.Add(Top:=.Top, Width:=.Width, Left:=.Left, Height:=.Height)
With myBox
.LinkedCell = ColManipulate & myCell.Row
.Caption = ChkBoxCaption
If Astr = "True" Then .Value = 1 Else .Value = 0
.Name = "checkbox_" & myCell.Address(0, 0)
End With
End With
Next myCell
End With
End Sub