Unable to get the CheckBoxes property of the Worksheet class

bartsimpsong

New Member
Joined
Jun 24, 2014
Messages
14
Hello, I have been working on this small project and I it works to create checkboxes and check what boxes are checked. However, at the end of checking which boxes are checked there is a pop up error message saying Run-Time error '1004':
Unable to get the CheckBoxes property of the Worksheet class. These are the lines of code, can anybody see the error? Thank you very much

Sub IsBoxChecked()

Dim titles(200) As String
Dim wks As Worksheet
Dim nTitles As Integer
Dim totalCheckBoxes As Integer

totalCheckBoxes = 0

Set wks = ActiveWorkbook.Worksheets("Sheet1")

For i = 1 To 199
If Trim(wks.Cells(4, i).Value) = "" Then
nTitles = i - 1
Exit For
End If
titles(i - 1) = wks.Cells(4, i).Value
totalCheckBoxes = totalCheckBoxes + 1
Next

j = 1

For j = 1 To totalCheckBoxes
If ActiveSheet.checkBoxes(titles(j)).Value = 1 Then
MsgBox titles(j) & " CheckBox Is Checked"

Else
MsgBox titles(j) & " CheckBox is UnChecked"
End If
Next

End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
the worksheet does not have a property or method called checkboxes, use oleobjects instead
 
Upvote 0
Thank you very much for your help VBA Geek. I made the change you advised but I get the error message = Run-time error '1004'
Unable to get the OLEObjects property of the Worksheet class.

Sub IsBoxChecked()

Dim titles(200) As String
Dim wks As Worksheet
Dim nTitles As Integer
Dim totalCheckBoxes As Integer

totalCheckBoxes = 0

Set wks = ActiveWorkbook.Worksheets("Sheet1")

For i = 1 To 199
If Trim(wks.Cells(4, i).Value) = "" Then
nTitles = i - 1
Exit For
End If
titles(i - 1) = wks.Cells(4, i).Value
totalCheckBoxes = totalCheckBoxes + 1
Next

j = 0

For j = 0 To nTitles 'totalCheckBoxes
If ActiveSheet.OLEObjects(titles(j)).Value = 1 Then
MsgBox titles(j) & " CheckBox Is Checked"

Else
MsgBox titles(j) & " CheckBox is UnChecked"
End If
Next

End Sub

I appreciate any help. Also I would like to add the detail that it works good until the end when it finishes checking which box is checked with my original version, but when I change it to oleobjects it does not run at all.
 
Last edited:
Upvote 0
Code:
[COLOR=#333333]If ActiveSheet.OLEObjects(titles(j))[/COLOR][COLOR=#b22222][B].OBJECT.[/B][/COLOR][COLOR=#333333]Value = TRUE Then[/COLOR]
 
Upvote 0
Same error message my friend, thanks for trying

Run-time error '1004'
Unable to get the OLEObjects property of the Worksheet class.
 
Upvote 0

Forum statistics

Threads
1,214,989
Messages
6,122,622
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top