Results 1 to 2 of 2

Excel 2007 Code to Hide/Protect Worksheets

Threaded View

  1. #1
    Registered User
    Join Date
    12-09-2003
    Posts
    53

    Excel 2007 Code to Hide/Protect Worksheets

    Hello,

    Can you please help? I'm not a programmer. I have 43 worksheets in a workbook. Using buttons I want to protect worksheets, hide worksheets or unhide worksheets. Can I use a loop or if statement to easily do this instead of the current statements I'm using:

    sheets("Name1").visible = true
    sheets("Name2").visible = true
    sheets("Name3").visible = true
    etc....

    I've been playing with the if statement below which I found on this website but I'm getting a compile error message.

    Dim wsht as worksheet
    Dim i as integer
      if InputBox("Enter Password", "Password") <> "xxx"
        Then MsgBox "Incorrect Password", vbCritical
        Exit Sub
        Else For Each wsht in ThisWorkbook.Worksheets For i = 1 to 43    wsht.Visible=xlSheetVisible
                    Next i
                    Next wsht
                    End If
    End Sub
    Thank you much.
    Last edited by mab; 11-12-2010 at 03:59 PM. Reason: Comply With Forum Rule #3 -Code Tags

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