Saving a VBA function in personal workbook

TM74

Board Regular
Joined
Aug 2, 2007
Messages
132
Hi,

Is it possible to save a VBA function in your personal workbook, giving you access to it on all open spreadsheets?

I have tried it with one and it doesn't seem to work. Is there any way of doing this?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
The easiest way to create a personal.xls file is to Record a macro and store it to the "Personal Macro Workbook". You can choose this from the dropbox in the record new macro window.
 
Upvote 0
Thanks, I do that with many sub procedures which I have stored in the personal workbook. I added a module and put a function procedure in there.

I was wondering if there is a way to get that to work in all sheets (the same way a sub procedure would). Otherwise I think I wuld nbeed to add the function procedure to whichever sheets I wanted to use it in.
 
Upvote 0
When you say VBA function, do you mean a macro or a user-defined function? What is the code you are trying to save there? Also depending on if you have multiple instances of Excel open you might be trying to save it to a read-only version of your personal.xls file? Also you need to make sure that the code is genereic enough that it is not referencing incorrect sheets or ranges.

Hope that helps.
 
Upvote 0
Doh... I didn't read your post closely enough... you want a FUNCTION to be available. Yes, this can be done. Create a new workbook, make a module to store all of your functions in, then save the workbook as an addin (.xla) and store it in the AddIns folder for Excel. Be sure to restart Excel after you do this and make sure the addin you created is turned on under Tools>Add-Ins
 
Upvote 0
Scliern - yes it is a user defined function:

Function iColour(r As Range) As Integer
iColour = r.Interior.ColorIndex
End Function

I'll give MrKowz's solution a bash.

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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
Back
Top