Hi everyone.
I'm a little stuck and was wondering if someone could advise...I'm creating a script which writes a new script to a worksheet code-sheet within excel. I'm using the following code to do this where str_S_CFvb contains the created subroutine:
Workbooks("book2.xls").VBProject.VBComponents(Sheets("sheet3").CodeName).CodeModule.AddFromString str_S_CF_vb
The routine needs to be renamed to Sub CheckCells_[rangename](). I presume that you do this within the above string???
The [rangename] will be a custom name and will relate to the range that the sub routine actually checks within the worksheet.
The routine is activated by the ...calculation() subrountine in the sheet code:
Private Sub Worksheet_Calculate()
Me.OnCalculate = ActiveSheet.Name & ".CheckCells"
However I want a dynamic way of getting the ...calculate() sub routine to cycle through all subroutines on the same sheet that begin with 'Checkcells' as there may be a few sets of ranges (therefore subrountines) present. I'm presuming it'll be a variant to the uppermost bit of code posted but I'm not sure.
Hope someone can help and many thanks in advance
RodP
I'm a little stuck and was wondering if someone could advise...I'm creating a script which writes a new script to a worksheet code-sheet within excel. I'm using the following code to do this where str_S_CFvb contains the created subroutine:
Workbooks("book2.xls").VBProject.VBComponents(Sheets("sheet3").CodeName).CodeModule.AddFromString str_S_CF_vb
The routine needs to be renamed to Sub CheckCells_[rangename](). I presume that you do this within the above string???
The [rangename] will be a custom name and will relate to the range that the sub routine actually checks within the worksheet.
The routine is activated by the ...calculation() subrountine in the sheet code:
Private Sub Worksheet_Calculate()
Me.OnCalculate = ActiveSheet.Name & ".CheckCells"
However I want a dynamic way of getting the ...calculate() sub routine to cycle through all subroutines on the same sheet that begin with 'Checkcells' as there may be a few sets of ranges (therefore subrountines) present. I'm presuming it'll be a variant to the uppermost bit of code posted but I'm not sure.
Hope someone can help and many thanks in advance
RodP