Code to Create or Rename Subroutines from Inside a VBA Macro

Eldrod

Board Regular
Joined
Mar 11, 2010
Messages
76
I have a model containing some internal code that I want to be able to programmatically remove from the model before saving it as an "external" version. I searched and found code to remove an entire module that works great. However, now the resulting "external" file gets compiler errors when code is executed that contains a reference to one of the subroutines that were in the deleted module. Although I have coding to make sure the logic never hits the missing subroutines, the compiler doesn't know that. I think a workaround would be to either: 1) programmatically create a dummy stub subroutine with the same name that was in the deleted module, or 2) precode the dummy stub under a different name and programmatically rename the subroutine.
I have not been able to locate any coding or hints on how to do that. I'm hoping someone here has some ideas.
Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I have a model containing some internal code that I want to be able to programmatically remove from the model before saving it as an "external" version. I searched and found code to remove an entire module that works great. However, now the resulting "external" file gets compiler errors when code is executed that contains a reference to one of the subroutines that were in the deleted module. Although I have coding to make sure the logic never hits the missing subroutines, the compiler doesn't know that. I think a workaround would be to either: 1) programmatically create a dummy stub subroutine with the same name that was in the deleted module, or 2) precode the dummy stub under a different name and programmatically rename the subroutine.
I have not been able to locate any coding or hints on how to do that. I'm hoping someone here has some ideas.
Thanks!
UPDATE: I found code to create new modules and subroutines.
How can I create a Code Module in VBA
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top