Hiding CheckBoxes

smirker

New Member
Joined
Jun 19, 2012
Messages
9
HI, I'm hiding a column, but the checkboxes are still visible,

Here is the code

Sub FilterOH()
'
' Filters the OH Column
ActiveSheet.Unprotect ("unprotect")
ActiveSheet.Range("$A$9:$R$7084").AutoFilter Field:=19, Criteria1:="=TRUE", _
Operator:=xlAnd

' Hide the OH column
Columns("O:P").Select
Selection.EntireColumn.Hidden = True
Range("Q3").Select
'Protect the sheet
ActiveSheet.Protect Password:="protect"
End Sub

The problem is that each cell (o12:O778) has a checkbox linked to the adjacent cell in Column P

do I have to write a line of code to hide every single check box, or can I use some kind of range function for checkboxes?

thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
HI, I'm hiding a column, but the checkboxes are still visible,

Here is the code

Sub FilterOH()
'
' Filters the OH Column
ActiveSheet.Unprotect ("unprotect")
ActiveSheet.Range("$A$9:$R$7084").AutoFilter Field:=19, Criteria1:="=TRUE", _
Operator:=xlAnd

' Hide the OH column
Columns("O:P").Select
Selection.EntireColumn.Hidden = True
Range("Q3").Select
'Protect the sheet
ActiveSheet.Protect Password:="protect"
End Sub

The problem is that each cell (o12:O778) has a checkbox linked to the adjacent cell in Column P

do I have to write a line of code to hide every single check box, or can I use some kind of range function for checkboxes?

thanks

Hi,
You do not say which checkboxes you are using but following code may do what you want but I am assuming your checkboxes have their default name i.e. checkbox1 etc.

Dave

Sub FilterOH()
Dim myshape As Shape
Dim ws As Worksheet

Set ws = ThisWorkbook.Worksheets("Sheet1") '<< change name as required
'
' Filters the OH Column
With ws

.Activate
.Unprotect Password:="protect"
.Range("$A$9:$R$7084").AutoFilter Field:=19, _
Criteria1:="=TRUE", _
Operator:=xlAnd
' Hide the OH column
.Columns("O:P").EntireColumn.Hidden = True

.Range("Q3").Select '<< do you need to do this?
'hide checkboxes
For Each myshape In .Shapes

'Assumes all Check Boxes are default name i.e.
'"Check Box 1" "Check Box 2" and so on
If Left(myshape.Name, 5) = "Check" Then myshape.Visible = False
Next myshape

'Protect the sheet
.Protect Password:="protect"
End With

End Sub
 
Upvote 0
it depend upon which checkbox u r using from Form Control or ActiveX control

Code:
Form Control
'Hide All Checkboxes
Sheet1.CheckBoxes.Visible = False
'Hide Particular Checkbox
Sheet1.Shapes("Check Box 1").Visible = msoFalse

ActiveX Control
Sheet1.CheckBox1.Visible = False
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top