Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Calling a checkbox control with VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lee.marshall@transart.co.uk - 25 Jul 2007 12:36 GMT
Hi

Is there a way I can reference a checkbox item that I can manipulate
in VBA.

For instance...

I have a series of check boxes that I would like to change the
properties of with a loop

So my checkboxes are called:

CheckBox1
CheckBox2
CheckBox3
etc

and I want to be able to reference them like so:
For i = 1 to 20
"CheckBox" & i.Value = true
next i

Any ideas?
Bob Phillips - 25 Jul 2007 12:45 GMT
By the format of the name, I assume that they are control toolbox
checkboxes.

Dim oOLE As Object

   For Each oOLE In ActiveSheet.OLEObjects
       If TypeName(oOLE.Object) = "CheckBox" Then
           oOLE.Object.Value = True
       End If
   Next oOLE

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Hi
>
[quoted text clipped - 19 lines]
>
> Any ideas?
lee.marshall@transart.co.uk - 25 Jul 2007 13:33 GMT
Hi Bob

That is cool!

Just one other question. If I have a row of say 5 check boxes which I
have name CheckBox1a through CheckBox1e and then a new set of
checkboxes named CheckBox2a through CheckBox2e then
CheckBox3a through CheckBox3e

How can I reference them in such a way that if I select 'CheckBox2c'
then CheckBox2a, CheckBox2b, CheckBox2d and CheckBox2a become
unchecked.

Does that make sense?

Cheers!
Bob Phillips - 25 Jul 2007 16:42 GMT
Perfect sense Lee.

One question. How are you going to set these checkboxes? Will it be code in
each of the checkbox click events to set all of the others, or do you want
to loop through all checkboxes, and set the others in the group? If the
latter, you realise that if say 2a and 2b is set, it will always work on the
2a, unsettling 2b always.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Hi Bob
>
[quoted text clipped - 12 lines]
>
> Cheers!
lee.marshall@transart.co.uk - 25 Jul 2007 16:53 GMT
Hi Bob

Yes I have just been tinkering with method 2 of yours, and yes you are
right, it is very unsettling

Cheers
Bob Phillips - 25 Jul 2007 16:57 GMT
So what's the answer.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Hi Bob
>
> Yes I have just been tinkering with method 2 of yours, and yes you are
> right, it is very unsettling
>
> Cheers
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.