+ Reply to Thread
Results 1 to 2 of 2

Excel 2007 Code to Hide/Protect Worksheets

Hybrid 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

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Excel 2007 Code to Hide/Protect Worksheets

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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