Use cell like a checkbox

R

Rene

Hi experts,

I'm wondering, is there a way to format a cell so that it reacts like a
checkbox?

I want to simply toggle the content of a cell between "x" (selected)
and " " (empty= not selected) simply by clicking on a certain cell.

Thanks for your help!
Rene
 
G

Guest

You need VBA:

You can set-up a double-click event macro to perform this function.
 
E

edessary

Draw a Rectangle over cell A1 and format it to have no fill. Assign
the following macro to the Rectangle:

Sub Macro1()

If Range("A1") = "" Then
Range("A1") = "X"
Else
Range("A1") = ""
End If

End Sub

Click anywhere in your sheet to deselect the Rectangle.
Now everytime you click on cell A1 (that has a Rectangle on top of it)
the contents of A1 will change from X to blank or from blank to X.
 
R

Rene

Thanks,

that's really great... but.

is there no way to do this within the excel functions?

I would like to create a list, where each cell in one column is
"clickable".

With your description, I would have to modify the macro for each row.
I'm looking for a solution that I can simply copy (or pull) to other
rows. Is that possible in any way?

I appreciate your help!
Rene
 
E

edessary

I do not know of anyway to do what you are requesting with a function.
Try this and see if it will work better for you it does not require a
rectangle object. Paste the following into the code window for Sheet1
by right clicking on the tab for Sheet1 and selecting View Code:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

iCol = Application.ActiveCell.Column
iRow = Application.ActiveCell.Row

If iCol = 1 And iRow >= 1 And iRow <= 10 Then
If Cells(iRow, iCol) = "" Then
Cells(iRow, iCol) = "X"
Else
Cells(iRow, iCol) = ""
End If
End If

End Sub


It is currently set to work with Column A Rows 1-10. The problem with
this method is that the check will only change states when clicking on
a new cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top