-2

Passing function as parameter of another function

Sub transliterate() 
  somecode
  ...
  ...
  ...

  return word(a,b)
End Sub 

sub word(x,y)


end sub 
7
  • Does excel vba: Special Types - Functions as Arguments of Functions help? Commented Jan 21, 2019 at 10:14
  • What you're asking is not clear. Please use the edit link below the question to provide more information about what you're trying to ask. Commented Jan 21, 2019 at 10:26
  • Why would you not call a function direct from within another procedure/function? Commented Jan 21, 2019 at 11:51
  • Did I correctly understand your question, now? Commented Jan 21, 2019 at 12:15
  • i think yes but i am try to do something else, i am running it in Msword macros Commented Jan 21, 2019 at 12:23

1 Answer 1

1

VBA does not use return to pass back the result of a Function. VBA uses the following kind of construct, where the result is assigned to the function name. When End Function is reached the value assigned to the function's name is returned.

Sub testTransliterate()
  Dim a As String, b As String, Result As String

  a = "one"
  b = "two"
  Result = transliterate(x(a), b)
  Debug.Print Result
End Sub

Function x(a As String) As String
    x = a & " test"        
End Function

Function transliterate(x, y) As String
    Dim Result As String

   Result = y & ", " & x
   transliterate = Result
End Function
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.