Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 32
Default accessing CheckBox on Worksheet

create a command button
go into design mode
double click on the command button
paste this code:

Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
CheckBox1.Value = False
Else
CheckBox1.Value = True
End If

End Sub

exit design mode
click the command button



"German" <german.koninin@crm-worldwideDOTnet wrote in message
...
Hi.
I have a checkbox on one of the worksheets.
How can I access this checkbox programmatically in Excel?
Thanks a lot. I'm going to be crazy with this task.





  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 2
Default accessing CheckBox on Worksheet

It says "Unable to get OLEObject property of Worksheet class".


"Keith Willshaw" wrote in message
...

"Mike Tomasura" wrote in message
...
create a command button
go into design mode
double click on the command button
paste this code:

Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
CheckBox1.Value = False
Else
CheckBox1.Value = True
End If

End Sub


I dont think thats what he was asking though

From a VBA procedure you can get the value as follows

Dim MyFlag As Boolean
If ActiveSheet.OLEObjects("CheckBox1").Object.Value = True Then
MyFlag = True
End If
MsgBox MyFlag


Keith




  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 27,285
Default accessing CheckBox on Worksheet

Keith's code works for a checkbox from the control toolbox toolbar.

Perhaps you have a control from the Forms toolbar. If so
Dim MyFlag As Boolean
If ActiveSheet.Checkboxes("Check Box 1").Value = 1 Then
MyFlag = True
End If
MsgBox MyFlag

--
Regards,
Tom Ogilvy

"German" <german.koninin@crm-worldwideDOTnet wrote in message
...
It says "Unable to get OLEObject property of Worksheet class".


"Keith Willshaw" wrote in message
...

"Mike Tomasura" wrote in message
...
create a command button
go into design mode
double click on the command button
paste this code:

Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
CheckBox1.Value = False
Else
CheckBox1.Value = True
End If

End Sub


I dont think thats what he was asking though

From a VBA procedure you can get the value as follows

Dim MyFlag As Boolean
If ActiveSheet.OLEObjects("CheckBox1").Object.Value = True Then
MyFlag = True
End If
MsgBox MyFlag


Keith






  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 170
Default accessing CheckBox on Worksheet


"German" <german.koninin@crm-worldwideDOTnet wrote in message
...
It says "Unable to get OLEObject property of Worksheet class".


From a VBA procedure you can get the value as follows

Dim MyFlag As Boolean
If ActiveSheet.OLEObjects("CheckBox1").Object.Value = True Then
MyFlag = True
End If
MsgBox MyFlag



The code worked fine for me which suggests that either
you do not have an ActiveSheet or the code has a typo in
it. Note it must be 'OleObjects' not 'OleObject'

Please post your code here if you still have problems

Keith




"Keith Willshaw" wrote in message
...

"Mike Tomasura" wrote in message
...
create a command button
go into design mode
double click on the command button
paste this code:

Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
CheckBox1.Value = False
Else
CheckBox1.Value = True
End If

End Sub


I dont think thats what he was asking though



Keith






  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 2
Default accessing CheckBox on Worksheet

I got it!!
Thanks a lot Keith and Tom!


"Tom Ogilvy" wrote in message
...
Keith's code works for a checkbox from the control toolbox toolbar.

Perhaps you have a control from the Forms toolbar. If so
Dim MyFlag As Boolean
If ActiveSheet.Checkboxes("Check Box 1").Value = 1 Then
MyFlag = True
End If
MsgBox MyFlag

--
Regards,
Tom Ogilvy

"German" <german.koninin@crm-worldwideDOTnet wrote in message
...
It says "Unable to get OLEObject property of Worksheet class".


"Keith Willshaw" wrote in message
...

"Mike Tomasura" wrote in

message
...
create a command button
go into design mode
double click on the command button
paste this code:

Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then
CheckBox1.Value = False
Else
CheckBox1.Value = True
End If

End Sub


I dont think thats what he was asking though

From a VBA procedure you can get the value as follows

Dim MyFlag As Boolean
If ActiveSheet.OLEObjects("CheckBox1").Object.Value = True Then
MyFlag = True
End If
MsgBox MyFlag


Keith








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 in a protected worksheet Eric Wixom Excel Worksheet Functions 2 January 11th 08 04:15 PM
Checkbox to open another worksheet SLKoelker Excel Discussion (Misc queries) 3 August 21st 07 05:56 PM
checkbox and worksheet Jenn Excel Discussion (Misc queries) 2 June 26th 06 04:38 PM
error accessing a protected worksheet Erik Jahre Excel Worksheet Functions 0 February 24th 06 08:32 AM
Accessing Cells in Separate Worksheet mrjeffy321 Excel Discussion (Misc queries) 3 January 19th 06 11:58 PM


All times are GMT +1. The time now is 12:51 AM.

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"