PC Review


Reply
Thread Tools Rate Thread

Code for OptionBox

 
 
Noepie
Guest
Posts: n/a
 
      12th Dec 2008
Hello,

I have a sheet where people can choose between two options. I make use of
the OptionButton in the VBA Editor. What I want is that when Option 1 is
chosen, the worksheet fills in the value from A1 in to B1. When Option 2 is
chosen, the value from A2 should be filled in in to B1. How can I achieve
this?

Kind regards,

Noepie
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      12th Dec 2008
Assuming you are using the option buttons from the Controls command
bar not the Forms command bar, you can use code like the following:


Private Sub OptionButton1_Click()
Range("A1").Value = Range("B1").Value
End Sub

Private Sub OptionButton2_Click()
Range("A2").Value = Range("B1").Value
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Fri, 12 Dec 2008 00:20:00 -0800, Noepie
<(E-Mail Removed)> wrote:

>Hello,
>
>I have a sheet where people can choose between two options. I make use of
>the OptionButton in the VBA Editor. What I want is that when Option 1 is
>chosen, the worksheet fills in the value from A1 in to B1. When Option 2 is
>chosen, the value from A2 should be filled in in to B1. How can I achieve
>this?
>
>Kind regards,
>
>Noepie

 
Reply With Quote
 
Noepie
Guest
Posts: n/a
 
      12th Dec 2008
Thanx Chip!

"Chip Pearson" wrote:

> Assuming you are using the option buttons from the Controls command
> bar not the Forms command bar, you can use code like the following:
>
>
> Private Sub OptionButton1_Click()
> Range("A1").Value = Range("B1").Value
> End Sub
>
> Private Sub OptionButton2_Click()
> Range("A2").Value = Range("B1").Value
> End Sub
>
> Cordially,
> Chip Pearson
> Microsoft MVP
> Excel Product Group
> Pearson Software Consulting, LLC
> www.cpearson.com
> (email on web site)
>
>
>
>
> On Fri, 12 Dec 2008 00:20:00 -0800, Noepie
> <(E-Mail Removed)> wrote:
>
> >Hello,
> >
> >I have a sheet where people can choose between two options. I make use of
> >the OptionButton in the VBA Editor. What I want is that when Option 1 is
> >chosen, the worksheet fills in the value from A1 in to B1. When Option 2 is
> >chosen, the value from A2 should be filled in in to B1. How can I achieve
> >this?
> >
> >Kind regards,
> >
> >Noepie

>

 
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
Set OptionBox value via VBA Mark Burns Microsoft Excel Programming 2 20th Mar 2009 07:00 PM
How to set Optionbox value from code? Mark Burns Microsoft Excel Programming 2 5th Mar 2009 04:46 PM
Excel Checkboxs, Optionbox =?Utf-8?B?QnJhbmRvbg==?= Microsoft Excel Misc 0 2nd Nov 2006 04:03 PM
optionbox checkbox =?Utf-8?B?ZmxvdzIz?= Microsoft Excel Misc 3 24th Nov 2005 01:00 PM
checkboxes or optionbox Milton Snider Microsoft Access Forms 1 30th Jul 2004 12:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:17 AM.