Consulting

Results 1 to 9 of 9

Thread: PROTECT SHEET NAME

  1. #1

    PROTECT SHEET NAME

    using vba code How to prevent sheet tab names means user can't change sheet name ?

  2. #2
    Protect the workbook (Review tab).
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    If you don't have a large number of sheets to protect you can place this macro into each SHEET MODULE. Obviously you will
    need to change the sheet name in the macro to match the SHEET MODULE the macro is being pasted in.

    Private Sub worksheet_SelectionChange(ByVal Target As Excel.Range)
    
    
    If ActiveSheet.Name <> "Master" Then   '<--- edit sheet name to match existing name
    ActiveSheet.Name = "Master"   '<--- edit sheet name to match existing name
    End If
    End Sub
    
    

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Quote Originally Posted by Ash Koparkar View Post
    using vba code How to prevent sheet tab names means user can't change sheet name ?
    If you're worried that users will change the name on the tab of a worksheet and that might cause a macro to break:

    Worksheets ("Stores") subscript error because some user changed the name to Worksheets("Dept")

    I'd change the code name that the user doesn't see to something and use that in my macros.

    Then it doesn't matter is the user changes the name. You can always get it by using "Data.Name" in my example


    Capture.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5

    Thanx will try and also appreciate your suggestion.

    Quote Originally Posted by Logit View Post
    .
    If you don't have a large number of sheets to protect you can place this macro into each SHEET MODULE. Obviously you will
    need to change the sheet name in the macro to match the SHEET MODULE the macro is being pasted in.

    Private Sub worksheet_SelectionChange(ByVal Target As Excel.Range)
    
    
    If ActiveSheet.Name <> "Master" Then   '<--- edit sheet name to match existing name
    ActiveSheet.Name = "Master"   '<--- edit sheet name to match existing name
    End If
    End Sub
    
    

  6. #6

    Not working for me. Using Excel 2013


  7. #7
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    Did you paste it into the Sheet Level Module ?

  8. #8

    Yes ! but it not work

    Quote Originally Posted by Logit View Post
    .
    Did you paste it into the Sheet Level Module ?

  9. #9
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    See attached.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •