Not sure I understand what you are asking in relation to the code you have
posted.
Worksheet_Change events are triggered when a worksheet content changes, your
code suggests adding module code.
It might be better to describe what you intend to do?
--
Regards,
Nigel
(E-Mail Removed)
"Derek Brussels" <(E-Mail Removed)> wrote in message
news:A12E13E5-8E0A-4FC7-AB83-(E-Mail Removed)...
> Hello,
>
> I want a VBA procedure to create a Worksheet_change procedure for each
> sheet
> in a workbook.
> I have tried many things, but each time Excel and VBA are shut down.
>
> One Works fine:
> ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule.AddFromFile
> "C:\code.txt"
>
> Muliple does NOT work:
> For each sheet in activeworkbook.sheets
> sheet.activate
> ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule.AddFromFile
> "C:\code.txt"
> next
>
> Anyone?
>
> thank you,
> Derek