Calling procedures from Personal.xlsb

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,885
Office Version
  1. 365
Platform
  1. Windows
Can't find this in help anywhere............

I'm using Excel 2007.
Personal.xlsb is in the correct place.
When I try to call Personal.xlsb procedures from another workbook, I'm getting "Sub or function not defined."
The procedure I want to call is in a module in Personal.xlsb:
Code:
Public Sub msg(mess As String)
MsgBox mess
End Sub
If I put a calling procedure in the same module within Personal.xlsb it works fine, so the integrity of the basic bit of code's tested:...
Code:
Sub tst()
msg ("Hurrah!")
End Su

if I now try to call msg in the same way, but from a module in another workbook, I get the error.
Any ideas?



Sub tst()
msg ("Hurrah!")
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi Richard

That's superb, thanks.

If you've got time, can you explain why you have to pass the arguments after the comma, and not in parentheses?

If not, thanks anyway!
 
Upvote 0
That's just the way Application.Run has been designed - you can check it out in VBA's help. Note that you can't pass object arguments using Application.Run so if you had a sub styled

Sub SomeSub(ws As Worksheet)
'
End Sub

you couldn't call this using Run as it expects an object argument but you can't pass it one. Just something to be aware of :)
 
Upvote 0
Just to add, the only time you use parentheses around arguments is if you are using the Call statement or if you are returning a value from a function.
 
Upvote 0
Thanks Rory. Learning all the time here.
 
Upvote 0

Forum statistics

Threads
1,215,276
Messages
6,124,007
Members
449,139
Latest member
sramesh1024

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