Make Excel Set Hello in Cell A1 When a Workbook Opens or Changes
Question details
Create a workbook-level VBA macro that writes Hello in cell A1 on every worksheet when the workbook opens and restores Hello if a user changes or clears A1.

- Product
- Microsoft Excel workbook with VBA macros
- Device & OS
- not provided
- Scenario
- The user wants a consistent default value in cell A1 across all worksheets without manually re-entering it.
- Observed behavior
- Cell A1 should contain Hello whenever the workbook opens and after a user edits, deletes, or clears that cell.
Use the desktop version of Excel and save the file in the Excel Macro-Enabled Workbook (*.xlsm) format. Open the Visual Basic Editor with Alt+F11 and place the event code in ThisWorkbook, not in an individual worksheet module.
Add Workbook_Open and Workbook_SheetChange events in ThisWorkbook
Use this method when Hello must be inserted at opening and automatically restored after A1 is changed on any worksheet in the workbook.
The Workbook_Open event checks every worksheet when the file starts. The Workbook_SheetChange event watches A1 and restores Hello after a user changes or clears it. Events are temporarily disabled while the macro writes to A1 so the macro does not trigger itself repeatedly.
In Excel, open the workbook and press Alt+F11. In the Project Explorer, expand the workbook project and double-click ThisWorkbook.
Paste the following code into the ThisWorkbook code window: Private Sub Workbook_Open() Dim ws As Worksheet Application.EnableEvents = False For Each ws In Me.Worksheets ws.Range("A1").Value = "Hello" Next ws Application.EnableEvents = True End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) On Error GoTo SafeExit If Not Intersect(Target, Sh.Range("A1")) Is Nothing Then If Sh.Range("A1").Value <> "Hello" Then Application.EnableEvents = False Sh.Range("A1").Value = "Hello" End If End If SafeExit: Application.EnableEvents = True End Sub
Select File > Save As, choose Excel Macro-Enabled Workbook (*.xlsm) from the Save as type list, and save the file.
Close and reopen the XLSM file. If Excel displays a security banner, select Enable Content so the Workbook_Open and SheetChange events can run.

Use an Excel template when only the initial A1 value is needed
Use a template instead of VBA when new workbooks only need to start with Hello in A1 and do not need to restore the text after it is deleted.
Use WPS Spreadsheets to keep Hello in cell A1 with VBA events
WPS Spreadsheets provides a familiar workbook and VBA workflow for macro-enabled spreadsheets. Add workbook event code in the VBA editor, save the file as XLSM, and enable macros to set Hello in A1 when the workbook opens or when users change the cell.
- 1. Open the macro-enabled workbook: Launch WPS Spreadsheets and open the XLSM workbook that needs the A1 automation.
- 2. Access the VBA editor: Use the Developer tools or press Alt+F11 to open the VBA editor, then select ThisWorkbook in the workbook project.
- 3. Insert the workbook event procedures: Paste the Workbook_Open and Workbook_SheetChange procedures into ThisWorkbook so they apply to every worksheet.
- 4. Save in XLSM format: Select Menu > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) to preserve the VBA project.
- 5. Enable macros when prompted: Reopen the workbook and allow macros so the event procedures can write Hello to A1.

Frequently Asked Questions
Where should I paste the Workbook_SheetChange macro?
Paste it in the ThisWorkbook module in the Visual Basic Editor. Do not paste it into Module1 or a single worksheet code module, because ThisWorkbook lets the event apply to all worksheets in that workbook.
Why does Hello not appear when I reopen the workbook?
Check that the file is saved as an XLSM workbook and that macros are enabled from Excel's security banner. The Workbook_Open procedure cannot run in an XLSX file or when macros are blocked.
Will this macro restore Hello after someone deletes A1?
Yes. Deleting or clearing A1 triggers Workbook_SheetChange, and the procedure writes Hello back into that worksheet's A1 cell.
Can I apply this automation to only one worksheet?
Yes. Replace the workbook-level SheetChange event with a Worksheet_Change event in the target sheet's code module, or add a condition such as If Sh.Name = "Sheet1" Then before changing A1.
Why is Application.EnableEvents used in the code?
Writing Hello to A1 triggers a change event itself. Setting Application.EnableEvents to False before writing prevents an endless event loop, and the SafeExit section turns events back on afterward.




