Consulting

Results 1 to 7 of 7

Thread: Don't to change name of sheets

  1. #1

    Don't to change name of sheets

    Hello,

    Someone can help me with this?

    I have a Workbook and I do not want to change the name to the Sheets.

    Thanks.

  2. #2
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Maybe, from menu Tools/Protection/Protect workbook/ check Structure and OK.

    Is OK?

    Artik

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I'm afraid I don't understand the question. Can you clarify your request?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    Quote Originally Posted by lucas
    I'm afraid I don't understand the question. Can you clarify your request?
    forgiveness for not explicitly state the question.

    I have a workbook that has 3 sheets called
    Cash Flow
    Tescmv
    Catalogo

    What I want is that VBA is not permitted to change the name of the worksheets.

    Greetings.

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If someone can run vba code in the workbook then this will be very hard to prevent.

    Artik has suggested the only method that would come close but that prevents users from changing anything in the workbook.

    Maybe I misunderstand still......is it possible that you want to protect the workbook or sheet using vba?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    VBAX Regular
    Joined
    Nov 2008
    Posts
    34
    Location
    There is one clever way to prevent this although it will seem absurd. You could write a naming macro for every possible event associated with the worksheet and then protect the vba editor/project with a password. See below.....

    Private Sub Worksheet_Activate()
    ThisWorkbook.Worksheets(1).Name = "Sheet1"
    End Sub

    Where "Activate" in the Private Sub title could be replaced by "Deactivate", "SelectionChange", "Change", etc,

    This is just an off the top solution.....but remember that when you must protect the VBA code part of this workbook (the vba project).

    Let me know if this works!

  7. #7
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Ischyros, that's a good idea.
    Rather than using the index, which can be changed by moving sheets, the code name, which can't be changed, could be used.
    [VBA]Sheet1.Name = "Sheet1" [/VBA]

    Its not clear to me that the OP wants to protect his workbook from VBA code. If he is only protecting himself against the user's keyboard and mouse, your routine (expanded to "rename" all sheets) could be put in ThisWorkbook's Workbook_SheetActivate event.

Posting Permissions

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