Microsoft Excel events can be used to rename a worksheet based on a value in a cell. Depending on what kind of manipulations are done with a cell driving a worksheet name, it needs to pick up a specific event to trigger renaming.
Good candidates for events are.
- SelectionChange
- Calculate
- Change
The best choice is Change worksheet event as it is triggered by any changes in a cell.
Let's consider a case when a cell is located in the same worksheet which we are going to rename. The cell is A1. A new workbook contains only 1 worksheet. The sample is developed in Microsoft Office Processional Plus 2016.
Open your Excel spreadsheet, then go to VBA Editor pressing Alt-F11 combination.

Add
Changeevent procedure selectingWorksheetin the first dropdown list andChangein the second one.
Add code to the event.
Set CellWithNewWorksheetname = Range("A1") If CellWithNewWorksheetname = "" Then Exit Sub Worksheets(1).Name = CellWithNewWorksheetnameThe event procedure is.

Return back to Excel and enter value in
A1cell.
tech jogging
Comments
comments powered by Disqus