Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Kuhaylah Malik   on Jan 29 In MS Office Category.

  
Question Answered By: Abejundio Garcia   on Jan 29

Funtions have limitations compared to subroutines. The following
quote comes from
http://www.j-walk.com/ss/excel/faqs/xl97faq3.htm

"Can a custom worksheet function written in VBA perform the same
types of actions as a subroutine?

No. Functions called from a worksheet formula have some limitations.
In general, they must be strictly "passive" -- they can't change the
active cell, apply formatting, open workbooks, change the active
sheet, and so on.

Functions can only perform calculations and return a value. An
exception to this rule is the VBA MsgBox function. A custom function
can display a MsgBox whenever it is recalculated. This is very handy
for debugging a custom function."

Possible options are to use a message box if you want to keep it as
a function, or use a subroutine and trigger your subroutine on the
Worksheet_Change event, button press, or another event.

Share: 

 
 
Didn't find what you were looking for? Find more on Inserting text in Textbox in Excel Or get search suggestion and latest updates.


Tagged: