Toggle button

Bertha

New Member
Joined
Jun 15, 2015
Messages
27
Is it possible to turn a cell into a toggle button?

Thank you for helping out,

Bertha
 
Change the code to
Code:
If .Value ="Y" Then
    .Interior.Color = RGB(0, 255, 0)
Else
    .Interior.Color = RGB(255, 0, 0)
End If
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Thank you Mike, that worked fine when I removed the lines:

If .Value Then
.Interior.Color = RGB(0, 255, 0)
Else
.Interior.Color = RGB(255, 0, 0)
End If

I will lose the colours, as I do not know how to set them (green for Y and red for N), but that is OK, I am happy with the Y/N instead of True/False.

Bertha

I managed to set the colour of cells containing Y to green and the colour of cells containing N to red dynamically via conditional formatting. Thank you for the earlier suggestion to do it that way.

Bertha
 
Upvote 0
Change the code to
Code:
If .Value ="Y" Then
    .Interior.Color = RGB(0, 255, 0)
Else
    .Interior.Color = RGB(255, 0, 0)
End If

Thank you! I tried something like:

If .Value =""Y" Then
.Interior.Color = RGB(0, 255, 0)
If .Value =""N" Then
.Interior.Color = RGB(255, 0, 0)
End If

After I noticed that didn't work I managed to assign colours via Conditional Formatting, but thanks for this example of how it can be done without Conditional Formatting.
 
Upvote 0

Forum statistics

Threads
1,215,382
Messages
6,124,620
Members
449,175
Latest member
Anniewonder

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