Consulting

Results 1 to 5 of 5

Thread: Solved: Show Hide Multiple Columns at once

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Show Hide Multiple Columns at once

    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:

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

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

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Hey,

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

    [VBA]
    ActiveSheet.Range("A:A").EntireColumn.Hidden
    [/VBA]




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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):
    [VBA]
    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
    [/VBA]

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




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  4. #4
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    thank you I didn't put it behind the form thank you

  5. #5
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    No problem! Glad to help




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •