ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Batch-modify checkboxes on Excel (https://www.excelbanter.com/excel-discussion-misc-queries/147489-re-batch-modify-checkboxes-excel.html)

Dave Peterson

Batch-modify checkboxes on Excel
 
Where are the checkboxes? I'm gonna assume that they're on a worksheet.

Are the checkboxes from the Forms toolbar or the control toolbox toolbar?

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim OLEObj As OLEObject
Dim CBX As CheckBox

Set wks = Worksheets("Sheet1")

'checkboxes from the Forms toolbar
For Each CBX In wks.CheckBoxes
With CBX
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End With
Next CBX

'checkboxes from the control toolbox toolbar
For Each OLEObj In wks.OLEObjects
With OLEObj
If TypeOf .Object Is MSForms.CheckBox Then
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End If
End With
Next OLEObj

End Sub




lillyanka wrote:

Is there a way to modify several checkboxes at the same time on excel?

I have about 30 checkboxes, and I need to link each one of them to a cell.
Is there a way to do it without going to the properties and changing them one
by one?

Thanks a lot!


--

Dave Peterson

lillyanka

Batch-modify checkboxes on Excel
 
They're from the control toolbox toolbar.

Thanks for your help!!

"Dave Peterson" wrote:

Where are the checkboxes? I'm gonna assume that they're on a worksheet.

Are the checkboxes from the Forms toolbar or the control toolbox toolbar?

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim OLEObj As OLEObject
Dim CBX As CheckBox

Set wks = Worksheets("Sheet1")

'checkboxes from the Forms toolbar
For Each CBX In wks.CheckBoxes
With CBX
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End With
Next CBX

'checkboxes from the control toolbox toolbar
For Each OLEObj In wks.OLEObjects
With OLEObj
If TypeOf .Object Is MSForms.CheckBox Then
.LinkedCell = .TopLeftCell.Address(external:=True)
.TopLeftCell.NumberFormat = ";;;"
End If
End With
Next OLEObj

End Sub




lillyanka wrote:

Is there a way to modify several checkboxes at the same time on excel?

I have about 30 checkboxes, and I need to link each one of them to a cell.
Is there a way to do it without going to the properties and changing them one
by one?

Thanks a lot!


--

Dave Peterson



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

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