+ Reply to Thread
Results 1 to 2 of 2

Hide/Unhide Column

Hybrid View

  1. #1
    Registered User
    Join Date
    10-08-2012
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2007/2010
    Posts
    1

    Hide/Unhide Column

    I'm trying to hide and unhide columns using a macro. Ideally it should require a password to unhide. this is what I have so far


    Sub View()
    ' View Macro
    ' Keyboard Shortcut: Ctrl+v
    '
        Columns("G:N").Select
        ActiveSheet.Unprotect
        Selection.EntireColumn.Hidden = False
        Range("N6").Select
    End Sub
    Sub Hide()
    ' Hide Macro
    ' Keyboard Shortcut: Ctrl+h
    '
        Columns("H:L").Select
        Selection.EntireColumn.Hidden = True
        ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
            False
    End Sub

    the view works fine but the hide hides ALL columns in the sheet. Can anyone help?
    Last edited by jeffreybrown; 10-08-2012 at 11:28 AM. Reason: Please use code tags when posting code...Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,296

    Re: Hide/Unhide Column

    Works fine for me.

    You don't need to select the columns. You can just use:

    Columns("H:L").EntireColumn.Hidden = True

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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