formatting any selected cell with one radio button

mphoenix5

New Member
Joined
Mar 26, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'd like to format the background of a cell (highlighted) yellow using a radio button. I'd then like select another cell and use the same radio button to highlight that cell yellow as well. Any additional cell not highlighted, the radio button will be solid (or a center dot). When the cells previously highlighted are selected, the radio button will be "hollow." Clicking on the radio button again (with the background formatted yellow), the background format will be removed and the radio turn solid (or a center dot).

I hope this makes sense.
Thx Mike
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I don't see how this is possible as described, unless I'm not understanding - or unless you plan to use a counter.
select cell, button goes off (white center)
click button (on = black center) active unformatted cell goes yellow
click another unformatted cell, button goes off
click button on (black center), active unformatted cell goes yellow. So far, so good.
Any additional cell not highlighted, the radio button will be solid (or a center dot).
That is the opposite of the above. How can button be in the same condition for both formatted and unformatted cells? The only way would be to reverse the logic upon reaching a particular count? Or is it 'reverse all that' then would it work?
 
Upvote 0
As long as you're clicking on cells, why not just double click the cell and make it yellow if it's not, white (or clear its formatting) if it is?
 
Upvote 0
I don't see how this is possible as described, unless I'm not understanding - or unless you plan to use a counter.
select cell, button goes off (white center)
click button (on = black center) active unformatted cell goes yellow
click another unformatted cell, button goes off
click button on (black center), active unformatted cell goes yellow. So far, so good.

That is the opposite of the above. How can button be in the same condition for both formatted and unformatted cells? The only way would be to reverse the logic upon reaching a particular count? Or is it 'reverse all that' then would it work?
I may have made this unnecessarily complicated. I made the assumption a radio button changes it’s look when selected. It doesn’t matter if it does or not.

What is primarily my desire is to have a single radio button change the shading (to yellow) of any cell currently selected (active). If the radio button (or check box, or whatever) is selected again (without leaving that current cell, the shading would be removed.

So, any non shaded cell selected would be shaded if that one radio button is clicked. If any shaded cell is selected, and the radio button clicked, that cell would become non shaded.

Does that help Macron?
 
Upvote 0
As long as you're clicking on cells, why not just double click the cell and make it yellow if it's not, white (or clear its formatting) if it is?
Just trying to reduce the effort by non excel savvy users.
 
Upvote 0
Not trying to be argumentative or overly persuasive, but isn't clicking on a cell then clicking on a userform option button just as much effort? Even more due to the mouse move required to get to the button? Actually, you don't say if the buttons are on a form or not, but it would still involve a mouse move from cell to sheet button. No matter I guess, because
If the radio button (or check box, or whatever) is selected again (without leaving that current cell, the shading would be removed.
I'd say that the problem is, an option (radio) button, once clicked, won't "unclick" when you click it again - you need to click a different button in order to "un-select" it. Not even selecting another control (e.g. textbox) will unselect the button. Also, the click event won't fire if it's already selected so this might be a bit trickier than it seems. If a simple double click isn't an attractive solution, I (or whoever beats me to this - I have family coming over soon) will have to figure out what event(s) to use. Either that, or you need to involve at least 2 buttons.
 
Upvote 0
Not trying to be argumentative or overly persuasive, but isn't clicking on a cell then clicking on a userform option button just as much effort? Even more due to the mouse move required to get to the button? Actually, you don't say if the buttons are on a form or not, but it would still involve a mouse move from cell to sheet button. No matter I guess, because

I'd say that the problem is, an option (radio) button, once clicked, won't "unclick" when you click it again - you need to click a different button in order to "un-select" it. Not even selecting another control (e.g. textbox) will unselect the button. Also, the click event won't fire if it's already selected so this might be a bit trickier than it seems. If a simple double click isn't an attractive solution, I (or whoever beats me to this - I have family coming over soon) will have to figure out what event(s) to use. Either that, or you need to involve at least 2 buttons.
Two buttons would be fine… identified as “shade” and un-shade.” (Or shaded and unshaded.)
 
Upvote 0
try these - create one click even for each.
for undoing:

With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With

for yellow:
ActiveCell.Interior.Color = vbYellow
 
Upvote 0
Thank you for your suggestions. Here's pretty much what I was looking for... using a Toggle button:

Private Sub ToggleButton2_Click()
' Toggle the color for selected cells
If TypeName(Selection) = "Range" Then
Dim r As Range
For Each r In Selection
If r.Interior.Color = RGB(255, 255, 255) Then '//<~~ NOTE the RGB value
r.Interior.Color = RGB(255, 255, 0)
Else
r.Interior.Color = RGB(255, 255, 255)
End If
Next r
End If

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,657
Messages
6,120,776
Members
448,991
Latest member
Hanakoro

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