PC Review


Reply
Thread Tools Rate Thread

How do I set option button value using VBA

 
 
=?Utf-8?B?RGFuIFRob21wc29u?=
Guest
Posts: n/a
 
      11th Jul 2007
I have a option button control on my spread sheet and I want to be able to
set the value to either True or False using VBA code.

How do I refer to that object with in my Worksheet.

What I am trying to do is have VBA set will say OptButton1 to False upon the
workbook being closed.

Keep in mind the option button is an object in a worksheet Not a control on
a User Form.

Please Anyone , Help ?
Dan Thompson
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hhcmxpZQ==?=
Guest
Posts: n/a
 
      11th Jul 2007
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets("Sheet1").OptionButton1 = False

End Sub

"Dan Thompson" wrote:

> I have a option button control on my spread sheet and I want to be able to
> set the value to either True or False using VBA code.
>
> How do I refer to that object with in my Worksheet.
>
> What I am trying to do is have VBA set will say OptButton1 to False upon the
> workbook being closed.
>
> Keep in mind the option button is an object in a worksheet Not a control on
> a User Form.
>
> Please Anyone , Help ?
> Dan Thompson

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Jul 2007
I wouldn't put it in the code before the workbook closes. The user can still
answer no to the save prompt (or you could save without asking and maybe damage
the workbook???).

I'd put the code in a procedure that runs when the workbook opens:

Option Explicit
Sub Auto_Open()
worksheets("sheet999").optionbutton1.value = false
end sub



Dan Thompson wrote:
>
> I have a option button control on my spread sheet and I want to be able to
> set the value to either True or False using VBA code.
>
> How do I refer to that object with in my Worksheet.
>
> What I am trying to do is have VBA set will say OptButton1 to False upon the
> workbook being closed.
>
> Keep in mind the option button is an object in a worksheet Not a control on
> a User Form.
>
> Please Anyone , Help ?
> Dan Thompson


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to select option button in option group cm Microsoft Excel Programming 2 20th Oct 2009 04:49 PM
need help on how to grey out one option button in one group box based on the selection of another option button in another group box George Microsoft Excel Programming 13 11th Mar 2007 02:08 PM
Scanning Option Group (VB 6 Option Button Control Array) Michael D. Ober Microsoft VB .NET 6 21st Jun 2006 06:55 AM
keep source formatting is not an option in paste option button =?Utf-8?B?VGluYQ==?= Microsoft Excel Misc 0 20th Feb 2006 09:58 PM
Sleep button option hide in power option properties =?Utf-8?B?RXJhcmQgRGF2aWQ=?= Windows XP General 3 29th Jun 2004 03:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:41 PM.