+ Reply to Thread
Results 1 to 9 of 9

macro to hide sheets

  1. #1
    ditchy
    Guest

    macro to hide sheets

    Hello there,
    would anyone be able to help me with this please.
    I have a workbook with 100+ sheets and I need to hide all but two
    until a password is entered, then the rest of the sheets can be viewed.
    All help is appreciated
    Thanks, Ditchy


  2. #2
    Bob Phillips
    Guest

    Re: macro to hide sheets

    The password routine is simple and not robuts, but may suit your purpose

    Sub HideSheets
    For Each sh In Activeworkbook.Worksheets
    If sh.Name <> "some name" And sh.Name <> "some other name" Then
    sh.Visible = xlSheetHidden
    End If
    Next sh
    End Sub

    Sub ShowSheets
    Dim sPass
    sPass = Inputbox ("Supply password")
    If sPass = "abc" Then
    For Each sh In Activeworkbook.Worksheets
    sh.Visible = xlSheetHidden
    Next sh
    End If
    End Sub

    --
    HTH

    Bob Phillips

    "ditchy" <[email protected]> wrote in message
    news:[email protected]...
    > Hello there,
    > would anyone be able to help me with this please.
    > I have a workbook with 100+ sheets and I need to hide all but two
    > until a password is entered, then the rest of the sheets can be viewed.
    > All help is appreciated
    > Thanks, Ditchy
    >




  3. #3
    ditchy
    Guest

    Re: macro to hide sheets

    Thanks for that info Bob,
    what I really need is when all the sheets are hidden except for the (3)
    I wan't left on view, they can be viewed. If there is a password given
    the rest of the hidden sheets become visable.
    thanks again
    Ditchy


  4. #4
    Bob Phillips
    Guest

    Re: macro to hide sheets

    Isn't that what I gave?

    --
    HTH

    Bob Phillips

    "ditchy" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks for that info Bob,
    > what I really need is when all the sheets are hidden except for the (3)
    > I wan't left on view, they can be viewed. If there is a password given
    > the rest of the hidden sheets become visable.
    > thanks again
    > Ditchy
    >




  5. #5
    ditchy
    Guest

    Re: macro to hide sheets

    Hi there Bob
    looking at your answer again yes it is, my problem is I have over 100
    sheets and I was hoping not to have to name them all for your macro, is
    there another way around it. Say name the 3 I want on view, hide the
    rest and to access the hidden only by password. If no password given
    still be able to veiw/edit the original 3 on view.
    Thank you for your patience
    regards
    Ditchy

    Bob Phillips wrote:
    > Isn't that what I gave?
    >
    > --
    > HTH
    >
    > Bob Phillips


    >
    > "ditchy" <[email protected]> wrote in message
    > news:[email protected]...
    > > Thanks for that info Bob,
    > > what I really need is when all the sheets are hidden except for the

    (3)
    > > I wan't left on view, they can be viewed. If there is a password

    given
    > > the rest of the hidden sheets become visable.
    > > thanks again
    > > Ditchy
    > >



  6. #6
    Bob Phillips
    Guest

    Re: macro to hide sheets

    I still think it is doing what you want, albeit with 2 names not 3.

    It will hide all but those two, and will unhide hidden sheets when a
    password is given.

    --
    HTH

    Bob Phillips

    "ditchy" <[email protected]> wrote in message
    news:[email protected]...
    > Hi there Bob
    > looking at your answer again yes it is, my problem is I have over 100
    > sheets and I was hoping not to have to name them all for your macro, is
    > there another way around it. Say name the 3 I want on view, hide the
    > rest and to access the hidden only by password. If no password given
    > still be able to veiw/edit the original 3 on view.
    > Thank you for your patience
    > regards
    > Ditchy
    >
    > Bob Phillips wrote:
    > > Isn't that what I gave?
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips

    >
    > >
    > > "ditchy" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Thanks for that info Bob,
    > > > what I really need is when all the sheets are hidden except for the

    > (3)
    > > > I wan't left on view, they can be viewed. If there is a password

    > given
    > > > the rest of the hidden sheets become visable.
    > > > thanks again
    > > > Ditchy
    > > >

    >




  7. #7
    ditchy
    Guest

    Re: macro to hide sheets

    Hi Bob,
    tried it again but it comes up with an error (unable to set the
    visable property of the worksheet class) (run-time error 1004), and
    also hides an extra sheet when password is entered.
    The sheets can still be accessed by Format /sheet /unhide,hide.
    not sure what to do from here, suggestions?
    regards
    Ditchy


  8. #8
    Bob Phillips
    Guest

    Re: macro to hide sheets

    Try this


    Sub HideSheets()
    For Each sh In Activeworkbook.Worksheets
    If sh.Name <> "some name" And sh.Name <> "some other name" Then
    sh.Visible = xlSheetVeryHidden
    End If
    Next sh
    End Sub

    Sub ShowSheets()
    Dim sPass
    sPass = Inputbox ("Supply password")
    If sPass = "abc" Then
    For Each sh In Activeworkbook.Worksheets
    sh.Visible = xlSheetVisible
    Next sh
    End If
    End Sub



    --
    HTH

    Bob Phillips

    "ditchy" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Bob,
    > tried it again but it comes up with an error (unable to set the
    > visable property of the worksheet class) (run-time error 1004), and
    > also hides an extra sheet when password is entered.
    > The sheets can still be accessed by Format /sheet /unhide,hide.
    > not sure what to do from here, suggestions?
    > regards
    > Ditchy
    >




  9. #9
    ditchy
    Guest

    Re: macro to hide sheets

    Thank you Bob
    will give this a try
    your help is much appreciated
    regards
    ditchy
    Bob Phillips wrote:
    > Try this
    >
    >
    > Sub HideSheets()
    > For Each sh In Activeworkbook.Worksheets
    > If sh.Name <> "some name" And sh.Name <> "some other name"

    Then
    > sh.Visible = xlSheetVeryHidden
    > End If
    > Next sh
    > End Sub
    >
    > Sub ShowSheets()
    > Dim sPass
    > sPass = Inputbox ("Supply password")
    > If sPass = "abc" Then
    > For Each sh In Activeworkbook.Worksheets
    > sh.Visible = xlSheetVisible
    > Next sh
    > End If
    > End Sub
    >
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "ditchy" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi Bob,
    > > tried it again but it comes up with an error (unable to set the
    > > visable property of the worksheet class) (run-time error 1004), and
    > > also hides an extra sheet when password is entered.
    > > The sheets can still be accessed by Format /sheet /unhide,hide.
    > > not sure what to do from here, suggestions?
    > > regards
    > > Ditchy
    > >



+ 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