Excel/Excel 2007 Add-In



I wish to seek advice on creating Add-In Excel 2007 on Win 7 64 bit machine.

I created a simple test.xlam file with one simple procedure and function each thus:
Sub s()
   ActiveSheet.Range("B2:G8").Interior.Color = vbGreen
   For i = 1 To 100000000
   Next i
   ActiveSheet.Range("B2:G8").Interior.Color = vbYellow
End Sub

Function f()
   ActiveSheet.Range("B2:G8").Interior.Color = vbGreen
   For i = 1 To 100000000
   Next i
   ActiveSheet.Range("B2:G8").Interior.Color = vbYellow
End Function

They are only for the purpose that I can see its action.

With a blank new workbook, I checked:
AddIns directory - empty;
Document directory - containing test.xlam file;
Add-Ins available dialog box - "test" is not listed.

Using Excel Options/Add-Ins/Manage Excel Add-Ins/Go/Browse
Test.xlam is added and checked as Active Application Add-Ins.

In the Alt+F8 macro dialog box, nothing is listed.
If I key in the procedure or function name, I can RUN them successfully.

if I call the procedure in another procedure, it shows "sub or function not defined"
if I key "=f()" in a cell, it shows "#VALUE" and nothing is performed.

Is there something I have missed or it is an Excel design feature please?



It sounds like you want to use addins, so there are a lot of things to know.  I would expect the "s" subroutine to be visible in the list of macros.  If it was, it would show as  


You need to make sure your procedures are in a general/standard module in the addin file.  In the vbe you would do Insert=>Module to get a general/standard module.  And it should not be declared private.

> if I call the procedure in another procedure, it shows "sub or function not defined"

so you can't just call s from another workbook without identifying where it is located.  Procedures are only visible to the workbook in which they are defined unless you set a reference to it.  Addins are more robust in this sense when they provide a function called from a worksheet.  

>if I key "=f()" in a cell, it shows "#VALUE" and nothing is performed.

The reason the =f()  doesn't work is that a user defined function used in this way is limited just like a built in function.  It is not allowed to alter the Excel environment.  It is only allowed to return a value to the cell in which it is called.  It can do calculations to come up with that value but it can not change the values or attributes of other cells.  So your "f" function is probably working, but the correct result is #Value since it is trying to do something illegal.

Also note that functions and subroutines that require arguments and private procedures do not display in the Macro dialog box (Alt+F8)

Jan Karel Pieterse has an extensive article on his site on add-ins. I think it will answer a lot of your questions and get you up and running.


Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.