Call another Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I call a workbook module in a worksheet module

Private Sub Commandbutton1_Click()
My Code
Then when complete call

Sub Update()

Thanks!
 
Private Sub Commandbutton1_Click()
' My Code
Update
End sub


or (less used)

Private Sub Commandbutton1_Click()
' My Code
Call Update()
End sub
 
Sandy,

In the worksheet's codemodule:

Private Sub Commandbutton1_Click()
'Your code here
Update
End Sub

In a regular module:
Sub Update()
'Your other code here
End Sub

HTH,
Bernie
MS Excel MVP
 
Tom Ogilvy wrote
Private Sub Commandbutton1_Click()
' My Code
Call Update()
End sub

Using XL2000 at least, I've found that Call Update works without the '()',
but I normally just use Update
 
Since there are no arguments for the Update Sub, that is true. I was trying
to emphasize that if you use the CALL syntax, that the arguments must be
enclosed in parentheses. Conversely, if you don't use call, they should not
be enclosed in parentheses unless it is a function returning a value that is
used by the calling program.
 
Tom Ogilvy wrote
Since there are no arguments for the Update Sub, that is true. I was
trying to emphasize that if you use the CALL syntax, that the
arguments must be enclosed in parentheses. Conversely, if you don't
use call, they should not be enclosed in parentheses unless it is a
function returning a value that is used by the calling program.

Understood. Thanks for the lesson.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top