View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Checkbox limitations

First, I would never use 1000 checkboxes on a worksheet. But if I had to, I
wouldn't use the checkboxes from the Control Toolbox Toolbar. Those controls
are very "intensive" in excel.

I'd use the checkboxes from the Forms toolbar. In my experience, the controls
from the Forms toolbar behave better and impact excel less. (But I still
wouldn't use that many!)

This added 2000 checkboxes with no problems:

Option Explicit
Sub LayOutCheckboxes()

Dim myCBX As CheckBox
Dim myCell As Range
Dim wks As Worksheet
Dim iCtr As Long

Set wks = ActiveSheet

Application.ScreenUpdating = False

iCtr = 0
With wks
.CheckBoxes.Delete 'nice for testing
For Each myCell In .Range("b1:b2000").Cells
With myCell
.NumberFormat = ";;;" 'hide the true/false
iCtr = iCtr + 1
If iCtr Mod 50 = 0 Then
DoEvents
Application.StatusBar _
= "Processing: " & myCell.Address(0, 0)
End If
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
'.OnAction = "'" & ThisWorkbook.Name & "'!CbxClick"
End With
End With
Next myCell
End With

With Application
.StatusBar = False
.ScreenUpdating = False
End With
End Sub

I did notice a slowdown on my pc when I got to about 1500 checkboxes.

Solution4U wrote:

This appears to be a repeatable problem.

Please advise if there is a fix for this, my email is

Here are the 2 posts from the forum:

"Solution4U" wrote:

I have 5 columns with over 100 check boxes in each. I keep getting an error
when the code runs unless I delete a certain portion of checkboxes. Right
now all is running well with 1195 checkboxes but if I add more I get the
error.

Does anyone know why this is happening or how to get around it?


I was only able to add 1098 check boxes using the code below with Excel 2003.
I could not find any limits listed in the excel help that explains this
problem.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10/13/2008 by Joel
'

'
LeftPos = Range("B1").Left

For RowCount = 2 To 4000 Step 2
TopPos = Range("B" & RowCount).Top
ActiveSheet.OLEObjects.Add _
ClassType:="Forms.CheckBox.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=LeftPos, _
Top:=TopPos, _
Width:=108, _
Height:=19.5
Next RowCount
End Sub

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...el.programming


--

Dave Peterson