.xla addin function

msvec

Board Regular
Joined
Feb 18, 2002
Messages
202
i have an addin that load automatically each time i open excel and it's full of subs that i use regularly and they work fine. i recently tried to add a function to one of the modules in the .xla file and when i'm in a spreadsheet, it won't work. if i move the function to a module specific to the sheet i'm in, no problems, but i would like to be able to include it in my .xla file.

any help in this area would be appreciated.

THANKS
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

hennahairgel

Board Regular
Joined
Feb 19, 2002
Messages
63
At the subroutine to the origianl sheet from which you created the add-in, and then saqve it as an add-in replacing the one with your current macros in it.
 

hennahairgel

Board Regular
Joined
Feb 19, 2002
Messages
63
At the subroutine to the origianl sheet from which you created the add-in, and then saqve it as an add-in replacing the one with your current macros in it.
 

hennahairgel

Board Regular
Joined
Feb 19, 2002
Messages
63
At the subroutine to the origianl sheet from which you created the add-in, and then saqve it as an add-in replacing the one with your current macros in it.
 

msvec

Board Regular
Joined
Feb 18, 2002
Messages
202

ADVERTISEMENT

I'm not sure i fully understand what you're saying. the addin loads successfully each time i open excel and the code for the function appears correctly. Do you want me to overwrite my existing .xla with a new one that includes this function?
 

dk

MrExcel MVP
Joined
Feb 15, 2002
Messages
2,942
It may be worth posting your function so that someone else can try it in one of their existing addins.
 

msvec

Board Regular
Joined
Feb 18, 2002
Messages
202
OK, here's the function:

Function countstr(cell_ref As Range, replace_val As String) As String

countstr = (Len(cell_ref) - Len(Replace(cell_ref.Value, replace_val, ""))) / Len(replace_val)

End Function
 

dk

MrExcel MVP
Joined
Feb 15, 2002
Messages
2,942
OK,

I just pasted your function into an add-in (for this purpose I pasted it into the modmenu module of the HTML Maker add-in). The function worked fine.

When you say it doesn't work do you mean it isn't available if you choose Insert, Function. Then choose User Defined from the left hand list. Is the function countstr visible in the right hand list? If so, what doesn't work when you choose that, add the two arguments and click OK?

If the countstr function isn't available can you confirm that you don't have this:-

Option Private Module

anywhere in the module containing the function?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,519
Messages
5,596,635
Members
414,083
Latest member
Mrsash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top