Making a Cell Manual Entry or Return Calculated Value Based Upon Ratio Button Selection

Brandon81

New Member
Joined
Jan 24, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I currently have a cell that the user inputs an numeric value into (highlighted in yellow). What I am trying to achieve is if the radio button selected is "YES" then user still can manually enter a value into the cell but if the radio button is "NO" then the same highlighted cell now returns a calculated value and can't be manually keyed/overwritten while selection is "NO". I am wondering if that is possible with conditional formatting or some other way. Is this possible and if so, how do I set this up?

1645188534460.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Candyman8019

Active Member
Joined
Dec 2, 2020
Messages
495
Office Version
  1. 365
Platform
  1. Windows
You'll need to use VBA for this. To start, the code that I'm putting here is for ActiveX radio buttons, not form radio buttons. One button is named 'yes' and the other 'no'. The grouping property should be set so that when one button is clicked, the other is turned off automatically. And lastly, this involves protecting the sheet...so any cells that you need to remain editable, must have be unlocked.
So, in the developer screen, go to the sheet where your buttons exist and paste this code. You can set the password to one of your choosing, and also set the formula to whatever you need it to be.

Private Sub Yes_Click()
ActiveSheet.Unprotect Password:="password here"
Range("B2").Locked = False
ActiveSheet.Protect Password:="password here"
End Sub

Private Sub No_Click()
ActiveSheet.Unprotect Password:="password here"
Range("B2").Value = "=C2+D2"
Range("B2").Locked = True
ActiveSheet.Protect Password:="password here"

End Sub
 

Forum statistics

Threads
1,175,610
Messages
5,898,437
Members
434,709
Latest member
Ev1lZer0

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
Top