Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Unset shape checkboxes with VBA

Hi NG,

I've got about 60 checkboxes on my spreadsheet (not in a user form!) and I'd
like to unset these checkboxes with VBA. So far I've come up with the
following:

Dim c As Shape

For Each c In ActiveSheet.Shapes
If Left(c.Name, 8) = "CheckBox" Then
ActiveSheets.Shapes.Object.Value = 0
End If
Next c

However, I cannot change the value, i.e. whether or not the checkboxes are
set or not. How do I address these shapes/checkboxes and set them to
unchecked?

--
Andreas


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Unset shape checkboxes with VBA

Sorry, found the solution myself ...


Dim c As Shape

For Each c In ActiveSheet.Shapes
If Left(c.Name, 8) = "CheckBox" Then
ActiveSheet.OLEObjects(c.Name).Object.Value = 0
End If
Next c

--
Andreas

"Andreas Emmert" schrieb im Newsbeitrag
...
Hi NG,

I've got about 60 checkboxes on my spreadsheet (not in a user form!) and

I'd
like to unset these checkboxes with VBA. So far I've come up with the
following:

Dim c As Shape

For Each c In ActiveSheet.Shapes
If Left(c.Name, 8) = "CheckBox" Then
ActiveSheets.Shapes.Object.Value = 0
End If
Next c

However, I cannot change the value, i.e. whether or not the checkboxes are
set or not. How do I address these shapes/checkboxes and set them to
unchecked?

--
Andreas




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Unset shape checkboxes with VBA

never say sorry for asking a question :)

in fact following would be a bit more efficient

a. it uses the object type thus making ik independent
of the name
b. it loops the oleobjects collection (subset of shapes)
c. it uses the variable c more efficiently
(u jump back to the entire collection using c.name, where you already
have the object c and could use c.object.value instead.


Sub UnCheck()
Dim c
For Each c In ActiveSheet.OLEObjects
If TypeName(c.Object) = "CheckBox" Then
c.Object.Value = 0
End If
Next
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Andreas Emmert" wrote:

Sorry, found the solution myself ...


Dim c As Shape

For Each c In ActiveSheet.Shapes
If Left(c.Name, 8) = "CheckBox" Then
ActiveSheet.OLEObjects(c.Name).Object.Value = 0
End If
Next c


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
Add and edit a shape in VBA Hugo Jorgensen Excel Discussion (Misc queries) 2 May 21st 23 11:48 AM
Specify shape dimensions SteveT Excel Discussion (Misc queries) 4 April 26th 10 09:41 PM
Shape coordinates [email protected] Excel Discussion (Misc queries) 0 April 3rd 07 04:21 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Automatique Shape Modeste Excel Discussion (Misc queries) 1 October 18th 05 04:03 PM


All times are GMT +1. The time now is 08:17 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"