Using Visual Basic in Excel to hide columns - TechRepublic
Question
March 4, 2008 at 08:42 AM
allan.thompson@ntlworld

Using Visual Basic in Excel to hide columns

by allan.thompson@ntlworld . Updated 17 years, 10 months ago

Hi there,

I am having a bad day…
I am trying to hide columns on a worksheet (“Fixtures”) by clicking a checkbox on “Data” sheet. But it doesn’t work! Seems fairly simple… but nothing happens when I check the box and I am stuck!

I have the code:-

Private Sub CheckBox1_Click()

Call sheetsunprotect: ‘ goto subroutine to unprotect all sheets and disable updating

‘ box checked
If CheckBox1.Value = True Then
‘ Code to hide data.
Worksheets(“Fixtures”).Select
Columns(“R:T”).Hidden = True
End If

‘box unchecked
If CheckBox1.Value = False Then
‘ Code to unhide data.
Worksheets(“Fixtures”).Select
Columns(“R:T”).Hidden = False
End If

Call sheetsprotect: ‘ goto subroutine to protect all sheets and disable updating

‘ go back to “Data” sheet
Worksheets(“Data”).Select

End Sub

Can anyone help?

Allan

This discussion is locked

All Comments