Form option buttons not working

lacogada

Board Regular
Joined
Jan 26, 2011
Messages
170
Code:
'   Transfers Amount
    If OptionButton1 Then Cells(Nextrow, 4) = TextBox4.Value
    If OptionButton2 Then Cells(Nextrow, 5) = TextBox4.Value

Problem is with OptionButton2

OptionButton2 is inputting TextBox value to col 4 and col 5.

As if OptionButton1 does not get turned off when I select OptionButton2.

Both option buttons are within a frame on a form.

OptionButton1 works correctly.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
If you place a frame on a form then insert option buttons inside the frame this would make them mutually exclusive, i.e., when you select on the other is deselected.

If you right click the option buttons and select Properties you can assign a GroupName which does the same thing.

If you mean to clear the cell which is populated by the deselected button you would need something like:

Code:
[COLOR=green]'  Transfers Amount[/COLOR]
   If OptionButton1 Then
      Cells(Nextrow, 4) = TextBox4.Value
      Cells(Nextrow, 5) = ""
   [COLOR=darkblue]End[/COLOR] If
    
   If OptionButton2 Then
      Cells(Nextrow, 5) = TextBox4.Value
      Cells(Nextrow, 4) = ""
   [COLOR=darkblue]End[/COLOR] If
 
Upvote 0
Thanks Bertie ...... your code fixed it.

.....and thanks for the tip about the "properties-group".
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top