ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   delete caption on multiple check boxes (https://www.excelbanter.com/excel-discussion-misc-queries/241401-delete-caption-multiple-check-boxes.html)

confused??

delete caption on multiple check boxes
 
I would like to add multiple check boxes (up to 1000) and link each check box
to it's corresponding cell as well as deleting the caption beside each check
box and have the check boxes centred in the cells.

Can anyone help me?

This is what i have so far but i can't work out how to delete the captions
and centre the checkboxes:

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

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("c2:c1000").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

Jacob Skaria

delete caption on multiple check boxes
 
Try the below

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

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("c2:c1000").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)

With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Width = .Height
.Left = .Left + (myCell.Width / 2) - (.Width / 2)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"confused??" wrote:

I would like to add multiple check boxes (up to 1000) and link each check box
to it's corresponding cell as well as deleting the caption beside each check
box and have the check boxes centred in the cells.

Can anyone help me?

This is what i have so far but i can't work out how to delete the captions
and centre the checkboxes:

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

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("c2:c1000").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


confused??[_2_]

delete caption on multiple check boxes
 
Thanks very much for the quick reply! That worked beautifully, thanks again!

"Jacob Skaria" wrote:

Try the below

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

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("c2:c1000").Cells
With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)

With myCBX
.LinkedCell = myCell.Address(external:=True)
.Caption = ""
.Width = .Height
.Left = .Left + (myCell.Width / 2) - (.Width / 2)
End With
.NumberFormat = ";;;"
End With
Next myCell
End With
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"confused??" wrote:

I would like to add multiple check boxes (up to 1000) and link each check box
to it's corresponding cell as well as deleting the caption beside each check
box and have the check boxes centred in the cells.

Can anyone help me?

This is what i have so far but i can't work out how to delete the captions
and centre the checkboxes:

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

With ActiveSheet
.CheckBoxes.Delete 'nice for testing
For Each myCell In ActiveSheet.Range("c2:c1000").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



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

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