Is there a way in VBA to check if a particular Sub exits inThisWorkbook?

G

Greg

I would like to be able to have my program check to see if a custom
Subroutine with a particular name exists in ThisWorkbook of VBA
Project (Book1) and call it if it exists. Is there a way to do this?

Greg
 
C

Charlotte E

I would like to be able to have my program check to see if a custom
Subroutine with a particular name exists in ThisWorkbook of VBA
Project (Book1) and call it if it exists. Is there a way to do this?


Well this method doesn't really 'test' if the Subroutine exists, but rather
try to call the Subroutine, and then just continue if it doesn't exists:


On Error Resume Next
Application.Run "Name of Subroutine"
On Error Goto 0


By using 'Application.Run' you'll also avoid any Compiler error if the
Subroutine doesn't exists upon execution of your code.

Hope this can solve your problem :)
 
Top