ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   i need a "radio button" -like feature in excel (https://www.excelbanter.com/excel-worksheet-functions/141042-i-need-radio-button-like-feature-excel.html)

jcarr25

i need a "radio button" -like feature in excel
 
I need to be able to click the cell and an "X" will appear or disappear. A
radio button would work, too.

Any help?

T. Valko

i need a "radio button" -like feature in excel
 
How about a double click event?

Try this macro.

Select the sheet where you want this to happen.
Right click on the sheet tab and select View Code
Paste this code into the right side of the window that opens:

Option Explicit

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("A1")) Is Nothing Then
With Target
If .Value = "X" Then
.Value = ""
Else: .Value = "X"
End If
End With
Cancel = True
End If
sub_exit:
Application.EnableEvents = True
End Sub

Hit ALT Q or click on the "X" to close the VBA editor.

Double click in cell A1 and a "X" will appear. Double click again and the
"X" will disappear.

Adjust the range where you want this to happen by changing this line of
code:

If Not Intersect(Target, Range("A1")) Is Nothing Then

For example, if you want the range to be A1:A10:

If Not Intersect(Target, Range("A1:A10")) Is Nothing Then

Biff

"jcarr25" wrote in message
...
I need to be able to click the cell and an "X" will appear or disappear. A
radio button would work, too.

Any help?





All times are GMT +1. The time now is 03:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com