OptionButton value to change from True/False to Yes/No

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Please can someone help me?

I would like to change the optionbutton value from true to Yes and False to No. Is this possible?

This is the code I have at the moment:
Code:
Sheets("Data").Cells(lrcd + 1, "D").Value = OptionButton1.Value

Sheets("Data").Cells(lrcd + 1, "D").Value = OptionButton2.Value

OptionButton1 is labelled as Yes and OptionButton2 as No.

Regards

Dan
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
An option button has two Boolean values of either True or False. So if you write the code to use the OptionButton.Value you will get the Value based on current status of the button. Selected = True, unselected = False. To get a value of "Yes" or "No" to display in a cell, you would need to write the code something like this.
Code:
If OptionButton1.Value = True Then
 Sheets("Data").Cells(lred + 1, "D") = "Yes"
ElseIf OptionButton2.Value = False Then
 Sheets("Data").Cells(lred + 1, "D") = "No"
End If
 
Upvote 0
Hi JLGWhiz,

You code has worked just as I wanted, Thank you.

Kind Regards

Dan
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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