Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a sub in personal.xlsb from with in a VBA module

Status
Not open for further replies.

msc121

Programmer
Oct 3, 2020
1
0
0
US
There must be an easier way to call subroutines in personal.lxsb from a VBA sub! I suspect I'm doing it wrong.
Calling a sub in my personal.lxsb is a pain. i.e wsOutLastRow = Application.Run("'" & "personal.xlsb" & "'!FindLast", "Row", "BP") it's the only way i know.

Is there some way to #include modules in external projects to simplify calling, i.e. wsOutLastRow = FindLast(“row”,”bp”)?

Please excuse if I’m not using the right terminology. I’ve been a programmer, off and on, for 40 years but, until now strictly top-down . This is my first foray into Object oriented programming and to much of it is still voodoo.


I'm trying to think but nothing happens. -- Curly
 
I have never used personal.xlsb, but have for a long time used Add-Ins to achieve the capability you seem to be seeking.
 
You need to let know the code in your workbook know that the code in other workbook exists. You have two options here:
- as Deniall wrote, create add-in, this makes its code public,
- give VBAProject in personal unique name and reference it in the workbook.

The third option is what you are doing now, force excel to execute procedure by passing its name.

combo
 
To be slightly more explicit about combo's second option: Personal.xlsb should open whenever you open Excel (but will be hidden, if you created it correctly); rename the project from the default VBAProject to something hopefully unique, and you can then add it as a VBA reference (Tools>References). And can then use the public methods and public functions directly, just like an add-in.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top