ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Adding a Checkbox in Cells (https://www.excelbanter.com/excel-discussion-misc-queries/88633-adding-checkbox-cells.html)

Chaplain Doug

Adding a Checkbox in Cells
 
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.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org

Norman Jones

Adding a Checkbox in Cells
 
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


---
Regards,
Norman



Chaplain Doug

Adding a Checkbox in Cells
 
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


--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Norman Jones" wrote:

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


---
Regards,
Norman




Dave Peterson

Adding a Checkbox in Cells
 
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



Chaplain Doug wrote:

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

--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org

"Norman Jones" wrote:

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


---
Regards,
Norman




--

Dave Peterson


All times are GMT +1. The time now is 02:55 PM.

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