Be the first user to complete this post

  • 0
Add to List

Excel-VBA : Prevent Changing the WorkSheet Name

Many a times you need a scenario where you don't want user to change the worksheet name in you Excel work book.

Its quite easy to do.

Steps:

  • Go to VBA Editor
  • Expand your VBA Project
  • Select the any Sheet
Select WorkSheet
Select WorkSheet
  • Now select the "WorkSheet" from the first drop down on the right
Select WorkSheet from dropdown
Select WorkSheet from dropdown
  • Select the SelectionChange from the second drop down on the right
Select SelectionChange
Select SelectionChange
  • Now you will see the function Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  • Add the following code in the function.
If Sheet9.Name <> "FixedName" Then

   Sheet9.Name = "FixedName"

End If
Code
Code

And thats it you are done. Lets test our program.

Go to excel and try changing the worksheet name.

Prevent changing the sheet name
Prevent changing the sheet name



Also Read:

  1. VBA-Excel: Create Dynamic or Run-time WorkSheets using Macro.
  2. VBA-Excel: Edit And Save an Existing Word Document
  3. Excel-VBA : Prevent Adding New Worksheet
  4. VBA-Excel: Convert Numbers (Rupees) into Words OR Text - Updated Till 1000000 Crore With Decimal Numbers
  5. VBA-Excel: Working with Bookmarks- Insert text before Bookmark
  6. VBA Excel - Cells, Ranges and Offset : Range
  7. VBA-Excel: Fill Excel Range Values in a 2D Array
  8. Excel-VBA : Open a Excel File using Another Excel File using Browse Option.