Using VBA To Delete Thousands of Checkboxes <p>Somehow 10s of thousands of checkboxes were created in some spreadsheets that we have. I'm not sure how this happened but we cannot open the sheets in Excel 2010 only in Excel 2003 because of it. I wrote some VBA script to go through and delete the extra checkboxes and it works for most of the files. But, some files seem to have way more checkboxes than others and the script dies with an Out of Memory error. This is my script:</p> <pre><code>Sub ProcessFiles() Dim Filename, Pathname, LogFileName As String Dim wb As Workbook Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Set log = fso.OpenTextFile("Z:\Temp\Fix.log", 8, True, 0) PrintLog ("*** Beginning Processing ***") Pathname = "Z:\Temp\Temp\" Filename = Dir(Pathname &amp; "*.xls") Do While Filename &lt;&gt; "" PrintLog ("Opening " &amp; Pathname &amp; Filename) Set wb = Workbooks.Open(Pathname &amp; Filename) DoWork wb PrintLog ("Saving file " &amp; Pathname &amp; Filename) wb.Close SaveChanges:=True Filename = Dir() Loop log.Close End Sub Sub DoWork(wb As Workbook) Dim chk As CheckBox Dim c As Integer With wb Worksheets("Vessel &amp; Voyage Information").Activate PrintLog ("Getting count of checkboxes") c = ActiveSheet.CheckBoxes.Count PrintLog (c &amp; " checkboxes found") If (c &lt;= 43) Then PrintLog ("Correct # of checkboxes. Skipping...") Else c = 0 For Each chk In ActiveSheet.CheckBoxes If Not (Application.Intersect(chk.TopLeftCell, Range("D29:D39")) Is Nothing) Then chk.Delete c = c + 1 End If Next PrintLog ("Deleted " &amp; c &amp; " checkboxes.") End If End With End Sub Public Sub PrintLog(argument As String) If Not log Is Nothing Then log.WriteLine Format(Now(), "yyyy-MM-dd hh:mm:ss") &amp; ": " &amp; argument End If End Sub </code></pre> <p>The script fails at the <code>c = ActiveSheet.CheckBoxes.Count</code> in <code>DoWork</code> or, if I comment that line out, then at the <code>For Each chk In ActiveSheet.CheckBoxes</code>. I am guessing that calling <code>ActiveSheet.CheckBoxes</code> gathers up all the checkboxes and there are too many so it dies.</p> <p>Is there a way to step through each checkbox on a worksheet without using <code>ActiveSheet.CheckBoxes</code>?</p>