Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Personal.xlsb function in new workbook?

Tags:

excel

vba

I've searched around and I know how to call a function from Personal.xlsb from a VB macro, but how can I call the function to be used in a new workbook?

Here's my function, saved in 'Module1' in my Personal.xlsb:

Public Function GetColumnLetter(colNum As Integer) As String
    Dim d As Integer
    Dim m As Integer
    Dim name As String
    d = colNum
    name = ""
    Do While (d > 0)
        m = (d - 1) Mod 26
        name = Chr(65 + m) + name
        d = Int((d - m) / 26)
    Loop
    GetColumnLetter= name
End Function

I have created a new workbook and thought I could call that just by =getcolumnletter(1), but the function doesn't "populate" when I start typing =...

Am I overlooking something?? How do I use this function in other workbooks, without VBA?

Thanks for any advice!

like image 730
BruceWayne Avatar asked Aug 04 '15 17:08

BruceWayne


People also ask

How do I transfer personal XLSB?

If you want to share your Personal. xlsb file with others, you can copy it to the XLSTART folder on other computers. In Windows 10, Windows 7, and Windows Vista, this workbook is saved in the C:\Users\user name\AppData\Local\Microsoft\Excel\XLStart folder.

How do I make a custom function available for all workbooks?

An easier way to make your custom functions available at all times is to store them in a separate workbook and then save that workbook as an add-in (an XLA file) in your XLStart folder. (The XLStart folder is a subfolder of the folder containing your Excel files.

Where does Excel save personal XLSB?

Your Personal. xlsb file is stored in a folder called XLSTART. If you want to share your macros with someone else, you can copy it to the XLSTART folder on other computers, or copy some or all of its macros to the Personal.

How do I make a macro available in all Excel workbooks?

Steps to make Macro available in all Workbooks Go to Files > Options > Add-in and select the above Excel file/Macro from the list of Inactive Application Add-ins & Click Go. This step makes the function/macro available for all workbook.


1 Answers

Ah, it was more simple than I thought. Just use the workbook name before the macro - so

=Personal.xlsb![macroname]  

So in my case, I just put this into the cell: =Personal.xlsb!GetColumnLetter(2) to return "B".

like image 177
BruceWayne Avatar answered Sep 24 '22 16:09

BruceWayne