+ Reply to Thread
Results 1 to 4 of 4

Hide/unhide non adjacent columns

Hybrid View

nigelog Hide/unhide non adjacent... 08-12-2008, 08:00 AM
royUK Try Option Explicit ... 08-12-2008, 08:15 AM
nigelog Brilliant as always 08-12-2008, 08:56 AM
royUK Glad it helped. One macro is... 08-12-2008, 09:05 AM
  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Hide/unhide non adjacent columns

    Hi all
    I was trying to use a button to hide/unhide columns on a worksheet that are only used occasionally. I got as far as

    Columns("c:c").Hidden = True
    I wanted to add columns I,S and X but using a comma as a seperator would not work for me. Any ideas appreciated

    Rgds Nigel

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try

    Option Explicit
    
    Sub toggleColumns()
        With ActiveSheet.Range("C:C,I:I,S:S,X:X")
            .EntireColumn.Hidden = Not .EntireColumn.Hidden
        End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Brilliant as always

    Thanks Roy, the toggle option is better than I expected it could be. Rgds Nigel

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glad it helped. One macro is better than two in this case

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1