Overriding a built-in excel function with a macro or adding

Is it possible to override the built-in excel function using a custom macro from VBA or add-in? For example. I would like to redefine the SUM function and execute my own material there (SUM is just an example).

+6
excel-vba excel ms-office
source share
1 answer

This may be a simple question, but the answer is what every vba (excel) programmer should know:

There is a hierarchy that is observed when a function name collides.

Here is the priority structure:

  • 1st priority set for excel functions by default (e.g. Sum, Count, ...)
  • 2nd priority assigned to dll reference functions. (later ...)
  • Third priority provided by add-ins (e.g. Days360 - in case of Excel 2003)
  • 4th priority granted to module functions or custom user-defined UDF.

Also remember that in the second case, priority: If two or more references have the same function name (for example, if we refer to the ADO library and the DAO library together, there may be some collision of names), then the priority can be set manually by you requirement. In the Excel VBA IDE, go to Tools β†’ Links β†’ Select any library and in the right part of the window press β€œPriority” up / down to increase or decrease the priority of the function library.

Hope this helps everyone :)

+4
source share

All Articles