Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default VB codes for option buttons

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default VB codes for option buttons

Did you try my suggestion from yesterday of making sure that the option
buttons (from the control toolbox) are in the same group making the buttons
mutually exclusive (selecting one deselects the other). Or did you intend
something else.
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default VB codes for option buttons

yes Jim,I sent you the reply.the group names are correct, but I don't want it
manually.what I need is macro do it for me.many thanks

"Jim Thomlinson" wrote:

Did you try my suggestion from yesterday of making sure that the option
buttons (from the control toolbox) are in the same group making the buttons
mutually exclusive (selecting one deselects the other). Or did you intend
something else.
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default VB codes for option buttons

So if I understand you correctly you have 2 option buttons adna command
button. You wnat the command button to toggle the option buttons... If so then

Private Sub CommandButton1_Click()
With Sheet1
If .OptionButton1.Value = True Then
.OptionButton2.Value = True
Else
.OptionButton1.Value = True
End If
End With
End Sub
--
HTH...

Jim Thomlinson


"peyman" wrote:

yes Jim,I sent you the reply.the group names are correct, but I don't want it
manually.what I need is macro do it for me.many thanks

"Jim Thomlinson" wrote:

Did you try my suggestion from yesterday of making sure that the option
buttons (from the control toolbox) are in the same group making the buttons
mutually exclusive (selecting one deselects the other). Or did you intend
something else.
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default VB codes for option buttons

YOU ARE GREAT JIM THANK YOU SO MUCH!!!

"Jim Thomlinson" wrote:

So if I understand you correctly you have 2 option buttons adna command
button. You wnat the command button to toggle the option buttons... If so then

Private Sub CommandButton1_Click()
With Sheet1
If .OptionButton1.Value = True Then
.OptionButton2.Value = True
Else
.OptionButton1.Value = True
End If
End With
End Sub
--
HTH...

Jim Thomlinson


"peyman" wrote:

yes Jim,I sent you the reply.the group names are correct, but I don't want it
manually.what I need is macro do it for me.many thanks

"Jim Thomlinson" wrote:

Did you try my suggestion from yesterday of making sure that the option
buttons (from the control toolbox) are in the same group making the buttons
mutually exclusive (selecting one deselects the other). Or did you intend
something else.
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default VB codes for option buttons

Jim, what is the equivalent form_load in visual basic in VBA.you know what, I
want if the file is opened up, the 2 optin bottuns are not selected.in VB we
can have:
sub private form_load ()
optionbutton1.value=false
optionbutton1.value=false
or something like that.
any comment??

"Jim Thomlinson" wrote:

So if I understand you correctly you have 2 option buttons adna command
button. You wnat the command button to toggle the option buttons... If so then

Private Sub CommandButton1_Click()
With Sheet1
If .OptionButton1.Value = True Then
.OptionButton2.Value = True
Else
.OptionButton1.Value = True
End If
End With
End Sub
--
HTH...

Jim Thomlinson


"peyman" wrote:

yes Jim,I sent you the reply.the group names are correct, but I don't want it
manually.what I need is macro do it for me.many thanks

"Jim Thomlinson" wrote:

Did you try my suggestion from yesterday of making sure that the option
buttons (from the control toolbox) are in the same group making the buttons
mutually exclusive (selecting one deselects the other). Or did you intend
something else.
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default VB codes for option buttons

You can view an objects events by selecting the object in the (general) drop
down above the code window. When you make the selection the Declarations will
be populated in the drop down just to the right. So for example in the VBE
select sheet 1 which has the command buttons and option buttons embedded in
it. The General drop down will list the worksheet and all of the controls. By
selecting the sheet or the control you will get the event declarations in the
next drop down. Now just choose the event you want and a code stub will be
inserted.

You will also want to look at the Workbook objects stored in ThisWorkBook.
for more info check out Chip Pearson's web site at...

http://www.cpearson.com/excel/topic.aspx
--
HTH...

Jim Thomlinson


"peyman" wrote:

Jim, what is the equivalent form_load in visual basic in VBA.you know what, I
want if the file is opened up, the 2 optin bottuns are not selected.in VB we
can have:
sub private form_load ()
optionbutton1.value=false
optionbutton1.value=false
or something like that.
any comment??

"Jim Thomlinson" wrote:

So if I understand you correctly you have 2 option buttons adna command
button. You wnat the command button to toggle the option buttons... If so then

Private Sub CommandButton1_Click()
With Sheet1
If .OptionButton1.Value = True Then
.OptionButton2.Value = True
Else
.OptionButton1.Value = True
End If
End With
End Sub
--
HTH...

Jim Thomlinson


"peyman" wrote:

yes Jim,I sent you the reply.the group names are correct, but I don't want it
manually.what I need is macro do it for me.many thanks

"Jim Thomlinson" wrote:

Did you try my suggestion from yesterday of making sure that the option
buttons (from the control toolbox) are in the same group making the buttons
mutually exclusive (selecting one deselects the other). Or did you intend
something else.
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi,
I have a command button and two option buttons in my file and I need switch
between two option buttons(I mean selecting button1 or button2 alternatively)
by pressing the command box by means of VB codes.can anybody help me.
thanks

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
VB codes for option buttons peyman Excel Discussion (Misc queries) 3 September 19th 07 04:32 PM
option buttons help kb Excel Worksheet Functions 2 June 18th 07 11:06 PM
Using 'Option Buttons' Julian Excel Discussion (Misc queries) 3 August 17th 05 07:36 PM
Option Buttons Grant90 Excel Discussion (Misc queries) 1 July 29th 05 02:34 PM
Option Buttons Ashman Excel Discussion (Misc queries) 2 July 10th 05 08:24 PM


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