Hide columns using a button


If you need to hide certain columns using a button, you can use this code.  It will even change the command button text to Hide Columns and then again change it to Unhide Columns.


Sub Hide_C()

Dim C_ell As Range

ActiveSheet.Shapes.Range(Array(“Button 2″)).Select

If Selection.Characters.Text = “Unhide Columns” Then

Columns.Hidden = False

Selection.Characters.Text = “Hide Columns”


For Each C_ell In Range(“B1″, Cells(1, Columns.Count).End(xlToLeft))

If C_ell = “x” Then C_ell.Columns.Hidden = True


Selection.Characters.Text = “Unhide Columns”

End If


End Sub

2 thoughts on “Hide columns using a button

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>