vba code for calling a function

What is the proper syntax for calling a  Function from a subroutine in VBA for Excel?

Top Contributor Asked on February 12, 2018 in VBA: Development.
Add Comment
8 Answer(s)

Hi Victor,

Here is the solution to call a function from sub procedure.

Lets assume function is:

Function Function_Name()
'Statement 1
'Statement 2
'Statement 3
Function_Name=Result
End Function

Lets assume Procedure or subroutine is:

Sub Procedure_Name()
'Call function from procedure
'If there are no arguments you can directly call function without using keyword 'Call'
Function_Name
'or - 'If there are arguments you can call function with using keyword 'Call'
Call Function_Name
End Sub

Hope it clarifies your query.

Top Contributor Answered on February 13, 2018.
Add Comment

This answer is just what I was looking for.  Thank you.   Victor

Top Contributor Answered on February 14, 2018.
Add Comment

This answer was most helpful.  Thank you.

Top Contributor Answered on February 14, 2018.
Add Comment

Thank you.  This cleared it up.

Top Contributor Answered on February 14, 2018.
Add Comment

This answer was most helpful. Thank you.

Top Contributor Answered on February 14, 2018.
Add Comment

Thank you.  You answered my question.

Top Contributor Answered on February 15, 2018.
Add Comment

This answer was most helpful. Thank you.

Top Contributor Answered on February 16, 2018.
Add Comment

This answer was most helpful.  Thank you

Top Contributor Answered on February 16, 2018.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.