+ Reply to Thread
Results 1 to 3 of 3

VBA unhide columns

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-19-2013
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    297

    VBA unhide columns

    Hi guys,

    I am very new to VBA and have a basic knowledge.

    I need a macro to unhide columns. I have columns hidden in twos- so E:F, H:I, K:L are all hidden.

    I want to attach the macro to a command button and the macro initially to unhide E:F only, then H:I, then K:L. So unhide one set of columsn each time the user clicks the same button.

    I think it will be some sort of IF function- so if E:F is unhidden then unhide H:I and so on...

    I don't know how to do this though...

    Any ideas guys?

    Thanks in advance...

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA unhide columns

    Sub Macro1()
    
    If Range("E:F").EntireColumn.Hidden = true Then
        Range("E:F").EntireColumn.Hidden = false
    ElseIf Range("H:I").EntireColumn.Hidden = true Then
        Range("H:I").EntireColumn.Hidden = false
    ElseIf Range("K:L").EntireColumn.Hidden = true Then
        Range("K:L").EntireColumn.Hidden = false
    End If
    
    End Sub

  3. #3
    Forum Contributor
    Join Date
    04-19-2013
    Location
    Yorkshire, England
    MS-Off Ver
    Excel 2010
    Posts
    297

    Re: VBA unhide columns

    Thanks Yudlugar, I see, to remember you solved one of my problems the other day as well, so thanks for all your help!!

    Much appreciated!

    Quote Originally Posted by yudlugar View Post
    Sub Macro1()
    
    If Range("E:F").EntireColumn.Hidden = true Then
        Range("E:F").EntireColumn.Hidden = false
    ElseIf Range("H:I").EntireColumn.Hidden = true Then
        Range("H:I").EntireColumn.Hidden = false
    ElseIf Range("K:L").EntireColumn.Hidden = true Then
        Range("K:L").EntireColumn.Hidden = false
    End If
    
    End Sub

+ 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