Add WorkBook/WorkSheet macro

I want to add a macro for onSheetChange event handler.
I am able to add a module via workbook.VbaProject.Modules.Add(“ModuleName”, “VB Code”);
But I want to add the macro code in the WorkBook or Worksheet object.
Is there any way to do this ?

using .Net 6.

Hi Nishant,

Try this:

Dim worksheet = workbook.Worksheets(0)
workbook.VbaProject.Modules.Add(worksheet, "Macro for " & worksheet.Name)

Does this solve your issue?

Regards,
Mario