Dynamically add code to a new excel sheet

I need help regarding VBA. In my code, I add an excel sheet and rename it and add a checklist to it. I need to run some code to change the value in this checklist. And this should only be done when changing this particular cell. If I do not know, please let me know. Please help me solve this.

+5
source share
2 answers

Instead of trying to create separate code for each new sheet with the Visual Basic extension (see this link for further reading), just use the Workbook broadcast event Workbook_SheetChange(you need to put it in the module ThisWorkbook).

In this case, first check the code if the worksheet that raised the event is one of the newly created worksheets. This can be done most easily by checking the .Nameworksheet.

+7
source

you can use the Event SelectionChangeevent and Change, you can also use the module Thisworkbook. SheetChangeor SheetSelectionChange.

0
source

All Articles