473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VBA Excel - checkbox property for worksheet class

reginaldmerritt
201 100+
Hi,

Not used vb in excel before. Trying to get a button to set a lot of checkboxes to false.

Expand|Select|Wrap|Line Numbers
  1. For i = 15 To 103
  2.     ActiveSheet.CheckBoxes("Check Box " & i).Value = False
  3. Next
  4.  
I get the following message when i try to run the code.

Unbale to get the Checkbox property for worksheet class.

I searched online but don't really know what i'm looking for and all the solutions to errors for worksheet class seemed to centre around naming of sheets, but i haven't refered to any sheets in the code.

Any help would be great, thanks.
Mar 11 '11 #1

✓ answered by ADezii

The Original Check Boxes were created from the Forms Toolbar and not from the Controls Toolbox Toolbar. The Check Boxes from the Controls Toolbox are true ActiveX Controls, unlike those from the Forms Toolbar. I'm assuming that that was the difference in some manner.

11 16521
reginaldmerritt
201 100+
Thanks ADezii,

I've managed to get round it by selecting each realted cell and setting that to false so i'm using

Expand|Select|Wrap|Line Numbers
  1. Range("E24").Value = False
  2. Range("E25").Value = False
  3. Range("E26").Value = False
  4. Range("E27").Value = False
  5. Range("E28").Value = False
  6. Range("E29").Value = False
  7.  
and so on for each related cell. Be intrested if there is a better way.
Mar 11 '11 #2
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Dim ole As OLEObject
  2. Dim intCtr As Integer
  3.  
  4. 'Assuming your Check Boxes are name CheckBox15, CheckBox16,...CheckBox103
  5. 'You cannot have Spaces in Control Names, such as: 'Check Box 99'
  6. For intCtr = 15 To 103
  7.   ActiveSheet.OLEObjects("CheckBox" & CStr(intCtr)).Object.Value = False
  8. Next
Mar 11 '11 #3
reginaldmerritt
201 100+
Really, Excel just created the Check Boxes names with spaces.

Thanks very much ADezii, very much appreciated.

I'll give that a go. I think i'll stick to Access programming.
Mar 11 '11 #4
reginaldmerritt
201 100+
Comes up with the same message but this time for the OLEObjects.

Unable to get the OLEObjects property for Worksheet class

Oh well, thanks anyway. I can just use my other method for now.
Mar 11 '11 #5
ADezii
8,834 Expert 8TB
It's really puzzling to me as to why the Code is not working, so I created a Demo with three slightly different approaches in the hope that one may work for you. Download the Attachment, then see what happens from there.
Attached Files
File Type: zip Test.zip (23.1 KB, 360 views)
Mar 12 '11 #6
reginaldmerritt
201 100+
Thats great, many thanks for your time.

Sorry for not replying sooner, i've been away in Dublin on Holiday over the last few weeks.

The workbook you uploaded works fine but can't get the code to work in my workbook.

Active Sheet method gives me the same error message:
Unable to get the OLEObjects property for Worksheet class

Explicit Reference method does nothing at all

Loop and Filter method gives me the following error:
Method 'OLEObjects' of object '_Worksheet' failed

I'm also unable to save the worksheet as a normal excel document and have to save it as a macro enabled workbook , even though I'm not using any macros??; otherwise all the code is removed.

Must be something wrong with my workbook.
Attached Files
File Type: zip DiplomaUnitSelectionTool(QCF).zip (72.3 KB, 182 views)
Mar 21 '11 #7
ADezii
8,834 Expert 8TB
@reginaldmerritt - I have a Theory, but first see if the following works (converted to Excel 2003 Format).
Attached Files
File Type: zip DiplomaUnitSelectionTool.zip (85.0 KB, 284 views)
Mar 21 '11 #8
reginaldmerritt
201 100+
Many thanks ADezii.

The new button and check boxes you have put in have worked.

What did you do ????
Mar 30 '11 #9
ADezii
8,834 Expert 8TB
The Original Check Boxes were created from the Forms Toolbar and not from the Controls Toolbox Toolbar. The Check Boxes from the Controls Toolbox are true ActiveX Controls, unlike those from the Forms Toolbar. I'm assuming that that was the difference in some manner.
Mar 30 '11 #10
reginaldmerritt
201 100+
That was my first thought but when i tried to create ActiveX contorls on my own version of the workbook i still got the same error, but it works on your version.

hmmm., So back to the drawing board, i turned my version back to Excel 2003 and deleted all the checkboxs and started from scratch with new ActiveX chcekboxes. Started with just 5 and ran the code and hey presto it worked.

Turns out that i must have had missing checkboxs from the sequence with in the loop. i.e. in a for next loop
For i = x to y, y was to high, no checkbox existed with that number and this would cause the same error as trying to use the code with some Form Control checkboxes.

I now have all the checkboxes as ActiveX controls and in sequence as well. Everything working well.

Much appreciation for all your help and time ADezii
Mar 31 '11 #11
ADezii
8,834 Expert 8TB
The pleasure was all mine, glad it all worked out for you.
Apr 1 '11 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve Menard | last post by:
As par of JPype, I find that I have to brifge Java static members into class attributes. I am using a metaclass to dynamically create a Python class for every Java type encountered. Instance...
0
by: Bert | last post by:
Hi I am trying to add a property to a class that is derive from asp:placeholder. ? I have tried this but get an ambigous name error: Imports System.ComponentModel Imports System.Web.UI
4
by: Avi | last post by:
Hi I am creating web application in which i want to assign by default values to the property which i had created my own. In that one of the property is of type color and i am unable to assign...
9
by: tirrell payton | last post by:
Hello, I am trying to manipulate the properties of a form's controls from a class. I dont want to make the form's control public. Attached is a code snippet of what I am trying to accomplish:...
12
by: ssh | last post by:
function testfn(name) var tbody = document.getElementById('hellospace').getElementsByTagName('tbody'); var row = document.createElement('TR'); var cell1 = document.createElement('TD');...
4
by: joemo2003 | last post by:
In excel have one checkbox and one commondbutton. Inside the checkbox VBA, when if checkbox=true, then do a run and write a text to excel cell, when if checkbox=false, then remove the text in excel...
3
by: smugcool | last post by:
hi to all experts, I wrote a macro code, i got stuck in between as i am trying to import multiple excel workbooks variious sheets into an active worksheet. Requsting you to revert where i am...
6
FishVal
by: FishVal | last post by:
Hi, everybody. The thread title is actually the whole question. :) Does anybody know how to declare default method/property in Class module if it is possible at all? Any ideas/hints/links will...
6
by: Ang | last post by:
Is it possible to get the checkbox and radio button values from excel by c#? Thanks. *** Sent via Developersdex http://www.developersdex.com ***
1
by: itsNOTaTOOMAH | last post by:
I have an Access query and/or table that I'm exporting into an Excel spreadsheet using the TransferSpreadsheet action in VBA: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.