Excel Check Boxes, Even Simpler Way

Posted on September 15th, 2009 in Excel Howtos , Learn Excel - 7 comments

Add check-boxes to Excel - Form ControlsIn how to get tickmarks in excel, Jon (the Peltier, not the Stewart) commented,

[...] Better yet, use real checkboxes, so the user can change them with the mouse.

That got me thinking,

  • Who is this user we keep talking about :-?
  • Why not ?!?

In excel, you can add a check-box to spreadsheet using developer tools. See to the right:

But what if you needed a whole bunch of check-boxes?

Well, you could add one check box and copy paste the same a bunch of times. Only problem will be, all of them will refer to the same cell. Thus you check one, you check all. Checking out all might be a good option if you are in a party without a date. But, in excel, you need to be a bit more specific, no?

excel-check-boxesSo, I created a bunch of check boxes, each linked to one separate cell. And now, being the good, caring and lovable person I am, I have placed them for download. So go ahead and get your bunch of check boxes, while the supplies last.

Once you have the file, all you need to do is, copy paste as many check boxes to your workbook as you want (there are a total of 30 in there). Change the display text to whatever fancies you at the moment. And you are good to go.

Download the excel check boxes here.

*

I can imagine 2 colleagues in a cube farm talking,

Colleague 1: Wtf, the checkboxes don’t work.
Colleague 2: Didnt you get them from Chandoo.org?
Colleague 1: No, I added them myself.
Colleague 2: No wonder :P

| More
Subscribe for PHD Email updates and get a free excel e-book with 95 tips & tricks

Comments
Martin September 15, 2009

Be- a- utiful !!.

I believe though, the while purpose of the thread was to programatically add as many checkboxes as you need. I believe there are 2 approaches (at least) to do so:
1.- ask first “how many checkboxes do you need?”, and then add them using a macro.
2.- evaulate the content of a cell within a range, and determine if it’s empty or not, and if not (assuming there you put the expression you want to evaluate, which eventually can be used as the checkbox caption), then add the corresponding checkbox with its relative format.

Rgds.

dhammer September 16, 2009

I didn’t write this, but this bit of code works to add as many check boxes as you’d like. Here’s the link: http://www.terminally-incoherent.com/blog/2008/09/04/excel-adding-checkboxes-the-easy-way/

I used it for a project where I had to insert hundreds of check boxes – it even names the check box by the cell it resides in, quite helpful.

When you run the macro, it pops up three dialog boxes, the first you enter the cells you want the check boxes (A1:A12); in the second you enter the column you want the corresponding control to go (”A” if you want them to sit under the check boxes, “B” if you want them next to them etc.); and the third is where you’d type a label. There may be a way to have each label be different (or correspond to a cell, but I never use labels…)

And here’s the code:

Sub insertCheckboxes()

Dim myBox As CheckBox
Dim myCell As Range

Dim cellRange As String
Dim cboxLabel As String
Dim linkedColumn As String

cellRange = InputBox(Prompt:=”Cell Range”, _
Title:=”Cell Range”)

linkedColumn = InputBox(Prompt:=”Linked Column”, _
Title:=”Linked Column”)

cboxLabel = InputBox(Prompt:=”Checkbox Label”, _
Title:=”Checkbox Label”)

With ActiveSheet
For Each myCell In .Range(cellRange).Cells
With myCell
Set myBox = .Parent.CheckBoxes.Add(Top:=.Top, _
Width:=.Width, Left:=.Left, Height:=.Height)

With myBox
.LinkedCell = linkedColumn & myCell.Row
.Caption = cboxLabel
.Name = “checkbox_” & myCell.Address(0, 0)
End With

.NumberFormat = “;;;”
End With

Next myCell
End With
End Sub

Les September 16, 2009

I don’t know how he did it ….. but I’d like to know because it’s a neat trick and that’s why people limit them to just a few at a time.
Puzzled.

Yogesh Gupta September 17, 2009

There is another way to use Wingding chek boxes and change them with the double click with the help of macro

You can add as many of them by just defining the range in your macro. Values can be changed by just a double click.

You will furhter need to do data validation for that range so that user does not enter any other value by mistake.

Add following code to Sheet1 through VB Editor under microsoft excel obejects.

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

If Not Intersect(Target, Range(”G4:G14″)) Is Nothing Then
Cancel = True
If Target.Value = “þ” Then
Target.Value = “ý”

Else
Target.Value = “þ”
End If
End If

End Sub

Range G4:G14 will need to be formated with wingdings font.

You can download file containing this trick.
Change Value by double click.xls

This trick can be used to choose any values you want change with the double click and is not limited only to check boxes in wingdings.

Chandoo September 17, 2009

@Dhammer and Yogesh.. very good additions. I am too lazy to write the macro. But I know that is the best way to do it.

@Martin: thanks. I am sure you will more happy to see what Dhammer and Yogesh came up with.. :)

RSS feed for comments on this post. TrackBack URI

Leave a comment

   Name (required)

   E-mail (required, never displayed)

   URL


If you have a question, please ask in the forums

Recommended Excel, Charting, VBA books