Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Loop through SpinButtons on a Worksheet

Hi,

Is it possible to create a For Each statement to find all of the
SpinButtons on a specific sheet? I know the following code would find
the SpinButtons as shapes, but I need to have them as SpinButtons so
that I can programmatically alter the Max and SmallChange members of
the SpinButton class.

ie this will find the shapes, but not the SpinButtons:

Sub FindShapes
dim shp as shape
dim shps as shapes
set shps = Sheets(1).Shapes
For Each shp in shps
msgbox(shp.name)
Next
set shps = Nothing
End SUb

Any help would be greatly appreciated.. sorry if this is extremely
elementary but I am a Finance guy, not a programmer!

Thanks,
Rob

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Loop through SpinButtons on a Worksheet


A shape object has a "ControlFormat" property.
You can use that to access the properties of the actual control.
x = shp.ControlFormat.SmallChange
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Rob"
wrote in message
Hi,
Is it possible to create a For Each statement to find all of the
SpinButtons on a specific sheet? I know the following code would find
the SpinButtons as shapes, but I need to have them as SpinButtons so
that I can programmatically alter the Max and SmallChange members of
the SpinButton class.

ie this will find the shapes, but not the SpinButtons:

Sub FindShapes
dim shp as shape
dim shps as shapes
set shps = Sheets(1).Shapes
For Each shp in shps
msgbox(shp.name)
Next
set shps = Nothing
End SUb

Any help would be greatly appreciated.. sorry if this is extremely
elementary but I am a Finance guy, not a programmer!
Thanks,
Rob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Loop through SpinButtons on a Worksheet

Thanks for your reply. If I use the following code:

Sub SetSpinButtonParameters()
Dim Shp As Shape
Dim Shps As Shapes
Dim Sht As Worksheet
Set Sht = Sheets(1)
Set Shps = Sht.Shapes
For Each Shp In Shps
With Shp.ControlFormat
.Max = 100
.SmallChange = 10
End With
Next
Set Shps = Nothing
Set Sht = Nothing
Set Shp = Nothing
Set Sht_c = Nothing
End Sub

I get <Object doesn't support this property or method when the code
tries to set the max. I am not sure how to interpret this.

Thanks!
Rob

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Loop through SpinButtons on a Worksheet

BTW.. in my example immediately above.. all shapes in the sheet are
SpinButtons.

Thanks Again!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Loop through SpinButtons on a Worksheet


There are two types of controls that can be added to a worksheet.
This should work for the type you have...

Sub TellMeTheTruth()
Dim O_Object As OLEObject
For Each O_Object In ActiveSheet.OLEObjects
If TypeOf O_Object.Object Is MSForms.SpinButton Then
MsgBox O_Object.Object.SmallChange
End If
Next
End Sub


"Rob"

wrote in message
BTW.. in my example immediately above.. all shapes in the sheet are
SpinButtons.
Thanks Again!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Loop through SpinButtons on a Worksheet

That's just what I needed. Thanks for your help Jim!

-Rob

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
worksheet loop Don Guillett Excel Programming 1 December 7th 06 05:01 PM
Worksheet loop won't loop L. Howard Kittle Excel Programming 4 March 17th 06 12:56 AM
How do you define SpinButtons?? Skyhouse71 Excel Programming 1 March 10th 05 02:59 PM
worksheet loop scott[_8_] Excel Programming 8 November 17th 03 09:49 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM


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

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

About Us

"It's about Microsoft Excel"