• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hiding columns based on a checkbox

RogerMare

New Member
Hello,

I am not a programmer, my knowledge is very basic (excuse the pun) but I understand the concepts and the principles behind it. I also have a very strong grasp of how excel works and am very familiar with it.

I hope to do something fairly straightforward. When a checkbox is selected I want to hide a column on my worksheet.
To that end I have created a worksheet with a Checkbox (CheckBox3) and put n the following code:

Code:
Private Sub CheckBox3_Click()

Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = CheckBox3.Value

End Sub

However when you select the checkbox you get a runtime 424 object required error.

If possible I would rather avoid setting a value in a cell somewhere and just work directly from the properties of the checkbox.

Can anyone help, I am at a loss where to start.

thanks in advance.
Roger M
 
Here you go tried this works for me ........
Paste this into a empty macro .. and then connect to your check box
it will hide and unhide your column

Code:
Sub CB()


If Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = True Then
Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = False
Else
Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = True
End If
End Sub
 
Last edited:
Here you go tried this works for me ........
Paste this into a empty macro .. and then connect to your check box
it will hide and unhide your column

Code:
Sub CB()


If Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = True Then
Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = False
Else
Sheets("Client fwd plan").Columns("B").EntireColumn.Hidden = True
End If
End Sub

Thanks this worked well
 
Back
Top