PDA

View Full Version : Solved: Show Hide Multiple Columns at once



Djblois
02-27-2007, 03:10 PM
I created a form for my users to show or hide multiple columns at once but if they hide some columns and then later go back into the form the hidden columns are not checked. I tried to put this code behind the checkboxes and it still doesn't work:

If Active.Range("A:A").EntireColumn.Hidden = True Then
ColumnA.Value = True
End If

active is a worksheet object set to the active workbookand columnA is the name of the checkbox

malik641
02-27-2007, 03:37 PM
Hey,

I think you mean to use "ActiveSheet" rather than "Active":


ActiveSheet.Range("A:A").EntireColumn.Hidden

malik641
02-27-2007, 03:49 PM
My apologies, I didn't read your line after the code. Your code works for me. The checkbox comes up checked. Make sure your code for this is within the Userform_Initialize() event so when you load your form it will verify if the columns are hidden or not. Here's what I have (Within the Userform module):

Private Sub UserForm_Initialize()
Dim Active As Worksheet

Set Active = ActiveSheet

If Active.Range("A:A").EntireColumn.Hidden = True Then
ColumnA.Value = True
End If
End Sub


By the way, what do you mean "behind the checkboxes"? Did you put the code in an event of the check boxes?

Djblois
02-28-2007, 08:40 AM
thank you I didn't put it behind the form thank you

malik641
02-28-2007, 08:58 AM
No problem! :) Glad to help :thumb