ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I put a check box in each row of a column (https://www.excelbanter.com/excel-discussion-misc-queries/112233-how-do-i-put-check-box-each-row-column.html)

SteveK

How do I put a check box in each row of a column
 
I want to create check boxes for each row in a column. I was wondering if
there is a way to relate the check box to one cell and maybe drag the bottom
right corner down and have it copy down the row. Is there a way to do this or
another approach i might be able to use? Thanks ahead of time

Biff

How do I put a check box in each row of a column
 
Here's a macro by Dave Peterson.

Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("A2:A10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

Just change the range reference: ("A2:A10") to whatever you want. The macro
also sets the linked cell to be the same cell the checkbox is "in" and sets
the checkstate (TRUE or FALSE) to be "invisible". The Caption is set to no
caption. If you want the same caption in every checkbox you'll have to edit
that line. If you want a different caption in each checkbox then you'll have
to do it manually.

Biff

"SteveK" wrote in message
...
I want to create check boxes for each row in a column. I was wondering if
there is a way to relate the check box to one cell and maybe drag the
bottom
right corner down and have it copy down the row. Is there a way to do this
or
another approach i might be able to use? Thanks ahead of time




SteveK

How do I put a check box in each row of a column
 
awesome that worked out well. thanks for the help Biff

"Biff" wrote:

Here's a macro by Dave Peterson.

Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("A2:A10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

Just change the range reference: ("A2:A10") to whatever you want. The macro
also sets the linked cell to be the same cell the checkbox is "in" and sets
the checkstate (TRUE or FALSE) to be "invisible". The Caption is set to no
caption. If you want the same caption in every checkbox you'll have to edit
that line. If you want a different caption in each checkbox then you'll have
to do it manually.

Biff

"SteveK" wrote in message
...
I want to create check boxes for each row in a column. I was wondering if
there is a way to relate the check box to one cell and maybe drag the
bottom
right corner down and have it copy down the row. Is there a way to do this
or
another approach i might be able to use? Thanks ahead of time





Biff

How do I put a check box in each row of a column
 
We have Dave Peterson to thank. Thanks for the feedback!

Biff

"SteveK" wrote in message
...
awesome that worked out well. thanks for the help Biff

"Biff" wrote:

Here's a macro by Dave Peterson.

Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("A2:A10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

Just change the range reference: ("A2:A10") to whatever you want. The
macro
also sets the linked cell to be the same cell the checkbox is "in" and
sets
the checkstate (TRUE or FALSE) to be "invisible". The Caption is set to
no
caption. If you want the same caption in every checkbox you'll have to
edit
that line. If you want a different caption in each checkbox then you'll
have
to do it manually.

Biff

"SteveK" wrote in message
...
I want to create check boxes for each row in a column. I was wondering
if
there is a way to relate the check box to one cell and maybe drag the
bottom
right corner down and have it copy down the row. Is there a way to do
this
or
another approach i might be able to use? Thanks ahead of time







Keith-NB

How do I put a check box in each row of a column
 
Biff,
I used this macro and it worked great, except that by row 130 my checkbox
appears in row 129.

My row heights are consistent 25.50 or 34 pixels.

Is there some adjustment I can make to the macro to correct for this?

Thanks!
Keith



"Biff" wrote:

Here's a macro by Dave Peterson.

Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("A2:A10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

Just change the range reference: ("A2:A10") to whatever you want. The macro
also sets the linked cell to be the same cell the checkbox is "in" and sets
the checkstate (TRUE or FALSE) to be "invisible". The Caption is set to no
caption. If you want the same caption in every checkbox you'll have to edit
that line. If you want a different caption in each checkbox then you'll have
to do it manually.

Biff

"SteveK" wrote in message
...
I want to create check boxes for each row in a column. I was wondering if
there is a way to relate the check box to one cell and maybe drag the
bottom
right corner down and have it copy down the row. Is there a way to do this
or
another approach i might be able to use? Thanks ahead of time





Dave Peterson

How do I put a check box in each row of a column
 
I've had better luck when the zoom is set to 100%.

Any chance you're not using 100% zoom????

Keith-NB wrote:

Biff,
I used this macro and it worked great, except that by row 130 my checkbox
appears in row 129.

My row heights are consistent 25.50 or 34 pixels.

Is there some adjustment I can make to the macro to correct for this?

Thanks!
Keith

"Biff" wrote:

Here's a macro by Dave Peterson.

Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("A2:A10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

Just change the range reference: ("A2:A10") to whatever you want. The macro
also sets the linked cell to be the same cell the checkbox is "in" and sets
the checkstate (TRUE or FALSE) to be "invisible". The Caption is set to no
caption. If you want the same caption in every checkbox you'll have to edit
that line. If you want a different caption in each checkbox then you'll have
to do it manually.

Biff

"SteveK" wrote in message
...
I want to create check boxes for each row in a column. I was wondering if
there is a way to relate the check box to one cell and maybe drag the
bottom
right corner down and have it copy down the row. Is there a way to do this
or
another approach i might be able to use? Thanks ahead of time





--

Dave Peterson

Keith-NB[_2_]

How do I put a check box in each row of a column
 
Dave,
That was it. Thanks to you and Biff for the help.

Best,
Keith



"Dave Peterson" wrote:

I've had better luck when the zoom is set to 100%.

Any chance you're not using 100% zoom????

Keith-NB wrote:

Biff,
I used this macro and it worked great, except that by row 130 my checkbox
appears in row 129.

My row heights are consistent 25.50 or 34 pixels.

Is there some adjustment I can make to the macro to correct for this?

Thanks!
Keith

"Biff" wrote:

Here's a macro by Dave Peterson.

Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("A2:A10").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = "" 'or whatever you want
.Name = "CBX_" & myCell.Address(0, 0)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

Just change the range reference: ("A2:A10") to whatever you want. The macro
also sets the linked cell to be the same cell the checkbox is "in" and sets
the checkstate (TRUE or FALSE) to be "invisible". The Caption is set to no
caption. If you want the same caption in every checkbox you'll have to edit
that line. If you want a different caption in each checkbox then you'll have
to do it manually.

Biff

"SteveK" wrote in message
...
I want to create check boxes for each row in a column. I was wondering if
there is a way to relate the check box to one cell and maybe drag the
bottom
right corner down and have it copy down the row. Is there a way to do this
or
another approach i might be able to use? Thanks ahead of time




--

Dave Peterson



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

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