How do I store my VBA UDF?

C

cec34

I'm an old-time programmer, but new to VBA in Excel 2007. I've written a
UDF, but so far, I haven't figured out how to test it in the Immediate window
(or the worksheet, for that matter). It compiles without error, but how do I
store it to make it accessible to the associated worksheet?
 
N

Niek Otten

Don't store it in a Worksheet Module, but in a General Module. So, from the
VBA menu: Insert>Module and paste the code there.
Now you can call it from a worksheet as if it were a built-in Excel
function.
If you need to acces it from other workbooks or even distribute it: read
this:

http://www.jkp-ads.com/Articles/DistributeMacro00.asp

It says it is about macros, but most of it is true for functions as well
 
G

Gary''s Student

Put it in a standard module.

From the VBA window:

Insert > Module

then paste the stuff in. Consider making the UDF Public.
 
C

cec34

Thanks! That's what I needed.

cec34

Gary''s Student said:
Put it in a standard module.

From the VBA window:

Insert > Module

then paste the stuff in. Consider making the UDF Public.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top