LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to save the option button value

Hi,

I have a worksheet, depending on different choice in a dropdown list,
corresponding range which including a couple of option buttons should
be filled.


Here is an code sample:

If Worksheets("Sheet1").Range("E5").Value = "1" Then
Set rng = Worksheets("Sheet1").Range("E8:H10")
' Set all the value of option buttons in this range to false
' and disable all the option buttons
For Each obj In Worksheets("Sheet1").OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
If Not Intersect(obj.TopLeftCell, rng) Is Nothing Then
obj.Object.Value = False
obj.Object.Enabled = False
End If
End If
Next obj

Set rng1 = Worksheets("Sheet1").Range("E8:F10")
' enable the option buttons in the range(E8:F10)
For Each obj In Worksheets("Sheet1").OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
If Not Intersect(obj.TopLeftCell, rng1) Is Nothing Then
obj.Object.Enabled = True
End If
End If
Next obj

Else

If Worksheets("Sheet1").Range("E5").Value = "2" Then
Set rng = Worksheets("Sheet1").Range("E8:H10")
' Set all the value of option buttons in this range to false
' and disable all the option buttons
For Each obj In Worksheets("Sheet1").OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
If Not Intersect(obj.TopLeftCell, rng) Is Nothing Then
obj.Object.Value = False
obj.Object.Enabled = False
End If
End If
Next obj

Set rng1 = Worksheets("Sheet1").Range("G8:H10")
' enable the option buttons in the range(G8:H10)
For Each obj In Worksheets("Sheet1").OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
If Not Intersect(obj.TopLeftCell, rng1) Is Nothing Then
obj.Object.Enabled = True
End If
End If
Next obj

End if
End if

The basic idea of this code is: first, set the value of each option
button in the worksheet to false and disable all of them; then, based
on different choice in dropdown list, option buttons in specific range
enable.

After I ticked option buttons in specific range, I saved this
worksheet. However, I encountered one problem when I open this saved
worksheet. All the value of option buttons in the specific range
changed to false, no matter what I chose before save. I want to get the
worksheet with option button value saved.

Do you have some ideas to fix this problem? Thank you in advance!!!


Best Regards

Sam

 
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
Save as .xla option is not coming when I try to save Parag Excel Discussion (Misc queries) 3 January 28th 09 06:28 AM
Excel 2002 has no option to add the save as button to the toolbar- kselg Excel Discussion (Misc queries) 2 August 22nd 06 05:48 PM
How to diasble save and save as menu but allow a save button hon123456 Excel Programming 1 June 12th 06 09:50 AM
how to get disk icon on save button of save as dialog like 2000 RichT Excel Discussion (Misc queries) 2 March 9th 06 08:13 PM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM


All times are GMT +1. The time now is 06:45 AM.

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"