+ Reply to Thread
Results 1 to 11 of 11

how can i protect a single worksheet within a workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    03-11-2015
    Location
    Saudi Arabia
    MS-Off Ver
    2013
    Posts
    4

    Unhappy how can i protect a single worksheet within a workbook

    hello all

    i'm working in a college and i make the ongoing assessments, and within each assessment workbook i put extra worksheet as copyright for my work.
    but the problem i found that some guys deleting this sheet and replace another one with own names!!

    i tried to protect the sheet by using (protect sheet) but the problem still the same, they can't change anything but they can delete it
    i tried to protect the workbook by using (protect workbook), but it protect the whole file!

    can i protect only one single worksheet?

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: how can i protect a single worksheet within a workbook

    Did you try adding a password when you protect the worksheet? If not try
    ActiveSheet.Protect Password:="Password",
    and to unprotect
    ActiveSheet.UnProtect Password:="Password",
    Changing "Password" to a password of your choice
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: how can i protect a single worksheet within a workbook

    maybe this
    With ThisWorkbook
       .Protect Structure:=True, Windows:=False, Password:=123
       End With
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: how can i protect a single worksheet within a workbook

    Thanks again John, I just noticed that my code is for the active worksheet only.

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: how can i protect a single worksheet within a workbook

    hi gmr4evr1, you're welcome!

  6. #6
    Registered User
    Join Date
    03-11-2015
    Location
    Saudi Arabia
    MS-Off Ver
    2013
    Posts
    4

    Re: how can i protect a single worksheet within a workbook

    i'm so sorry guys, i did not get your point!

    how can i do that?

  7. #7
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: how can i protect a single worksheet within a workbook

    see this and try to add the code
    THISWORKBOOK.png

  8. #8
    Registered User
    Join Date
    03-11-2015
    Location
    Saudi Arabia
    MS-Off Ver
    2013
    Posts
    4

    Re: how can i protect a single worksheet within a workbook

    i tried it, it does not work

    the thing is that i want the feature of (protect workbook) and apply it to one single sheet, where (protect workbook) prevent the editing, deleting of the sheet.

    thank you anyway for your help
    i really appreciate your support

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: how can i protect a single worksheet within a workbook

    *keep in mind, if they wanna delete yr sheet/rename the file they will do!
    one way: you can try to prevent the saving if the sheet does not exist
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    'author Colo
    Dim sh As Worksheet, flg As Boolean
    For Each sh In Worksheets
    If sh.Name Like "Sheet3*" Then flg = True: Exit For
    Next
    If flg = True Then
    'MsgBox "Found!"
    Else
    SaveAsUI = False
    Cancel = True
    End If
    End Sub

  10. #10
    Registered User
    Join Date
    03-11-2015
    Location
    Saudi Arabia
    MS-Off Ver
    2013
    Posts
    4

    Re: how can i protect a single worksheet within a workbook

    that's brilliant one, thank you so much john55.

  11. #11
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: how can i protect a single worksheet within a workbook

    thank you for the feedback!
    if you are happy with the solution provided, please mark the thread as "solved". thx!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 05-13-2013, 08:44 AM
  2. Replies: 12
    Last Post: 01-21-2012, 12:40 PM
  3. Replies: 4
    Last Post: 03-06-2006, 10:35 AM
  4. [SOLVED] Passwords Disappear in OpenOffice (Protect Worksheet, and Protect Workbook)
    By msnews.microsoft.com in forum Excel General
    Replies: 6
    Last Post: 12-27-2005, 04:20 AM
  5. Can protect worksheet then workbook but not Protect and Share in code
    By ctmom@comcast.net in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2005, 11:05 AM

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