Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Using Checkbox Values

I'm having a bit of trouble using checkbox values.

When I create a checkbox (using the control toolbox), right click and select
view code, the code opens in the worksheet in which it is created as a
private sub.

I want to be able to use the True\False value of this checkbox in a module,
but because it is private I cannot pass the value across.

I'm usually OK at all this but i'm getting frustrated with using controls,
any help (even simple help!) appreciated.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Using Checkbox Values

Hi

While it's true the even code is designated Private by default, you
can still access the Checkbox's value from a normal sub eg given that
I have created a checkbox on Sheet1, then the following sub (in
Module1) produces different output dependent on whether the checkbox
is checked or not:

Sub test()
If Sheet1.CheckBox1 Then MsgBox "yes"
End Sub

Does this help?

Richard



On 5 Mar, 06:44, D Zandveld
wrote:
I'm having a bit of trouble using checkbox values.

When I create a checkbox (using the control toolbox), right click and select
view code, the code opens in the worksheet in which it is created as a
private sub.

I want to be able to use the True\False value of this checkbox in a module,
but because it is private I cannot pass the value across.

I'm usually OK at all this but i'm getting frustrated with using controls,
any help (even simple help!) appreciated.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Using Checkbox Values

The event procedures are Private by default, but a worksheet is just a class
module, and as such you can make those procedures Public and then treat them
as a method of that class. By that, I mean that you can call those
procedures as long as you have an instance of that class, and you qualify
the procedure with that class instance. As it so happens, you do have such a
class instance, Excel/VBA creates one for every worksheet when the workbook
is opened, implicitly.

So, if the codename (the name that a worksheet is known internally to VBA)
of a worksheet is Sheet1, you can call the event procedure like so

Call Sheet1.CheckBox1_Click

Similarly, as Richard shows, you can get at the checkbox directly

Sheet1.CheckBox1.Value

BUT ... you can more easily link the checkbox to a cell, LinkedCell is one
of the control's properties, and if you set that to a cell, you can read the
value directly from that cell.


--
HTH

Bob

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

"D Zandveld" wrote in message
...
I'm having a bit of trouble using checkbox values.

When I create a checkbox (using the control toolbox), right click and
select
view code, the code opens in the worksheet in which it is created as a
private sub.

I want to be able to use the True\False value of this checkbox in a
module,
but because it is private I cannot pass the value across.

I'm usually OK at all this but i'm getting frustrated with using controls,
any help (even simple help!) appreciated.

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox values? T135 Excel Worksheet Functions 2 January 12th 07 10:46 AM
Counting checkbox values VB Newbie[_2_] Excel Programming 2 November 23rd 05 01:51 PM
Importing Checkbox Values Marty Excel Programming 4 June 28th 04 07:05 PM
CheckBox values Allan[_4_] Excel Programming 1 December 22nd 03 05:02 PM
Checkbox values from a web client Larry[_10_] Excel Programming 1 September 11th 03 06:45 PM


All times are GMT +1. The time now is 11:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"