TheRedCardinal
Board Regular
- Joined
- Jul 11, 2019
- Messages
- 241
- Office Version
- 365
- 2021
- Platform
- Windows
Hi all,
I want to run a Subroutine when a user of my workbook leaves a sheet. I have written the code in the ThisWorkbook section of the book. It is called "Update Table".
I entered this in the Worksheet code section:
But it tells me the Sub is not defined.
Can I only run self-contained code in the Worksheet code section? Because there are 70 sheets that I want to do this with, and that's a lot of code to maintain when we make changes!
I want to run a Subroutine when a user of my workbook leaves a sheet. I have written the code in the ThisWorkbook section of the book. It is called "Update Table".
I entered this in the Worksheet code section:
VBA Code:
Private Sub Worksheet_Deactivate()
Call UpdateTable
End Sub
But it tells me the Sub is not defined.
Can I only run self-contained code in the Worksheet code section? Because there are 70 sheets that I want to do this with, and that's a lot of code to maintain when we make changes!
Last edited by a moderator: