ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro or VBA Code to un tick CheckBox (https://www.excelbanter.com/excel-programming/391488-macro-vba-code-un-tick-checkbox.html)

PA

Macro or VBA Code to un tick CheckBox
 
Dear All,

I have few checkbox at one tab of spreadsheet that assigned with few macro
if I tick that Checkbox.

Now, If I want to untick all that "ticked" Checkbox automatically by using
Macro/vba code, is there any vba code that I can use ?

I try to use macro recording to untick those checkbox, but it does not work.

Highly Appreciate for any comment and help,

Thansk alot,

PA

Leith Ross[_2_]

Macro or VBA Code to un tick CheckBox
 
On Jun 17, 10:29 pm, PA wrote:
Dear All,

I have few checkbox at one tab of spreadsheet that assigned with few macro
if I tick that Checkbox.

Now, If I want to untick all that "ticked" Checkbox automatically by using
Macro/vba code, is there any vba code that I can use ?

I try to use macro recording to untick those checkbox, but it does not work.

Highly Appreciate for any comment and help,

Thansk alot,

PA


Hello PA,

Here are 2 macros to do the job. The first macro is for Control
Toolbox CheckBoxes, like the ones on a UserForm, and the Excel
Worksheet only Forms Checkboxes.

'Begin Macro Code...
Sub ClearCheckBoxes1()

' This macro clears all Control Toolbox CheckBoxes on the
ActiveSheet
Dim CB As Object

For Each CB In ActiveSheet.OLEObjects
If TypeName(CB.Object) Like "CheckBox" Then
CB.Object.Value = ""
End If
Next CB

End Sub

Sub ClearCheckBoxes2()

' This macro clears all Forms CheckBoxes on the ActiveSheet
Dim CB As Object

For Each CB In ActiveSheet.CheckBoxes
CB.Value = xlOff
Next CB

End Sub
'End Macro Code

Sincerely,
Leith Ross


PA

Macro or VBA Code to un tick CheckBox
 
Dear Leith,

Thanks you very much for your help.It does work well

Best Regards

PA

"Leith Ross" wrote:

On Jun 17, 10:29 pm, PA wrote:
Dear All,

I have few checkbox at one tab of spreadsheet that assigned with few macro
if I tick that Checkbox.

Now, If I want to untick all that "ticked" Checkbox automatically by using
Macro/vba code, is there any vba code that I can use ?

I try to use macro recording to untick those checkbox, but it does not work.

Highly Appreciate for any comment and help,

Thansk alot,

PA


Hello PA,

Here are 2 macros to do the job. The first macro is for Control
Toolbox CheckBoxes, like the ones on a UserForm, and the Excel
Worksheet only Forms Checkboxes.

'Begin Macro Code...
Sub ClearCheckBoxes1()

' This macro clears all Control Toolbox CheckBoxes on the
ActiveSheet
Dim CB As Object

For Each CB In ActiveSheet.OLEObjects
If TypeName(CB.Object) Like "CheckBox" Then
CB.Object.Value = ""
End If
Next CB

End Sub

Sub ClearCheckBoxes2()

' This macro clears all Forms CheckBoxes on the ActiveSheet
Dim CB As Object

For Each CB In ActiveSheet.CheckBoxes
CB.Value = xlOff
Next CB

End Sub
'End Macro Code

Sincerely,
Leith Ross




All times are GMT +1. The time now is 01:41 PM.

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