If you want to learn a way to fix the name of the sheet using VBA then this article is for you.
In this article we will learn how to use VBA code in order to keep the same name for a worksheet i.e. if anyone wants to change the name then they are not allowed to do so.
Following is the snapshot of the worksheet contains two sheets; Permanent & Temporary
We need follow the below steps to fix the name of the Permanent sheet to “Permanent” itself.
- Click on Developer tab
- From Code group, select Visual Basic
- Enter the following code in the current worksheet module
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheet1.Name <> “Permanent” Then
Sheet1.Name = “Permanent”
- After copying the code; if we try to change the name of the “Permanent” sheet then excel will not allow us.
In this way we can ensure the same name of the worksheet as before.