gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
How can I write a VBA code to disable all events in all the workbook sheets and also the…
- User
How can I write a VBA code to disable all events in all the workbook sheets and also the code to enable all events
- Assistant
To disable all events in all workbook sheets, you can use the following VBA code:
Sub DisableEvents() Dim ws As Worksheet For Each ws In ThisWorkbook.Sheets ws.EnableEvents = False Next ws End SubTo enable all events, you can use the following VBA code:
Sub EnableEvents() Dim ws As Worksheet For Each ws In ThisWorkbook.Sheets ws.EnableEvents = True Next ws End SubThese codes use a loop to iterate through each worksheet in the workbook and set the
EnableEventsproperty toFalse(to disable events) orTrue(to enable events) for each sheet.