Three ways to rename a worksheet in Excel

Опубликовано: 22 Май 2026
на канале: Magic Excel - tips and tricks
826
12

If you want to automatically change the sheet name to the value in cell A1, you can use the following VBA code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim ws As Worksheet
Dim newName As String

On Error Resume Next
Set ws = ThisWorkbook.ActiveSheet ' Replace "Sheet1" with the sheet name
On Error GoTo 0

If Not ws Is Nothing Then
newName = ws.Range("A1").Value ' Get the value from cell A1
Application.EnableEvents = False ' Disable events to prevent recursive loop
ws.Name = newName ' Change the sheet name to the value in A1
Application.EnableEvents = True ' Re-enable events
End If
End Sub