Adding a Checkbox in Cells

G

Guest

Excel 2003. I know how to drag a checkbox from the control tool box onto a
sheet. What I really need (or want) to do is have every cell in a particular
column be a checkbox. How may I accomplish this? Thanks and God bless.
 
N

Norman Jones

Hi Chaplain Doug,
What I really need (or want) to do is have every cell in a particular
column be a checkbox. How may I accomplish this?

Using VBA, try:
'=============>>
Sub InsertCheckBoxes()
Dim rng As Range
Dim c As Range

Set rng = Range("A1:A20") '<<====== CHANGE

Application.ScreenUpdating = False
For Each c In rng.Cells
With ActiveSheet.CheckBoxes.Add(c.Left _
+ 5, c.Top - 2, 5, 5)
.Caption = ""
.LinkedCell = c.Address(False, False)
End With
c.Font.Color = vbWhite
Next c
Application.ScreenUpdating = True

End Sub
'<<=============

Change ("A1:A20") to your range of interest.

If you are not faniliar with macros, you may wish to visit David McRitchie's
'Getting Started With Macros And User Defined Functions' at:

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
G

Guest

Thanks Norman. Another question. Once I have these checkboxes in place, may
I reference their value as I do with other cells? That is,

ThisWorkBook.ActiveSheet.Cells(row, col).value
 
D

Dave Peterson

You could refer to the linked cell (true/false) (under the checkbox if you used
Norman's code).

Or you could just refer to the checkbox value itself.

if Activesheet.checkboxes("check box 1").value = xlon then
'checked
else
'not checked
end if
 

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