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
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,372
Office Version
  1. 2019
Platform
  1. Windows
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
 

Mahesh_P

New Member
Joined
May 24, 2012
Messages
47
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,483
Messages
5,596,405
Members
414,064
Latest member
Duncthegreat

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
Top