#IF directive to check if UDF is defined

ozloz

New Member
Joined
Aug 29, 2018
Messages
5
Hi gurus
I was just wondering if there was a directive that can work out if a subroutine or function (UDF) is defined in another VBA module within a workbook.
I have several modules that I often attach to workbooks; sometimes individually and sometimes together. Sometimes I use the same function within multiple modules so I don't have to include lots of unnecessary code
If the same UDF name is defined in multiple modules, using the function name in a sheet formula seems to result in an "amgiguous name" error even if said function is defined as private within the module.
Am I missing something here, or is there some #IF directive (or similar) that can check if the function is already defined in another module so it can be excluded.

Excel sheet formulas don't seem to respect the 'private' definition of functions within modules.

Something like
#IF DEFINED udf_name then
! Do nothing
#ELSE
function udf_name()
... code
end function
#ENDIF
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,213,491
Messages
6,113,963
Members
448,536
Latest member
CantExcel123

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