ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a way in VBA to check if a particular Sub exits inThisWorkbook? (https://www.excelbanter.com/excel-programming/426666-there-way-vba-check-if-particular-sub-exits-inthisworkbook.html)

Greg[_39_]

Is there a way in VBA to check if a particular Sub exits inThisWorkbook?
 
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

Jacob Skaria

Is there a way in VBA to check if a particular Sub exits in ThisWo
 
Dear Greg

Please refer http://www.cpearson.com/Excel/vbe.aspx

If this post helps click Yes
---------------
Jacob Skaria


"Greg" wrote:

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


Charlotte E

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

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 :-)






All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com