开发者

Overriding a builtin excel function with macro or add in

Is it possible to override a builtin excel function with a custom one from a VBA macro or from an add-in? E.g. I would like to override the SUM开发者_JAVA百科 function and perform own stuff there (SUM is only an example here).


This might be a simple question but the answer is something that every vba (excel) programmer should know well :

There is a hierarcy which is followed when there is function name clash.

Here is the structure with priority :

  1. 1st Priority given to default excel functions (e.g. Sum, Count, ...)
  2. 2nd Priority given to reference dll functions. (more later...)
  3. 3rd Priority given to add-in functions (e.g Days360 - in case of excel 2003)
  4. 4th Priority given to Module functions or custom UDF that you create.

Also remember, in 2nd priority case : If two or more references have same function name (e.g if we reference ADO library & DAO library together there might be some name clash), then priority can be manually set by you as per requirement. In Excel VBA IDE go to Tools >> References >> Select any library and on the right hand side of the Window click on Priority UP / Down to increase or decrease priority of the function library.

Hope this helps all :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜