Thread: Call a Function
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
mudraker[_346_] mudraker[_346_] is offline
external usenet poster
 
Posts: 1
Default Call a Function


Desert

You can call the function the same way unless you are expecting the
function to return data back to your macro or if you are passing
variable data onto the function

Sub Macro1()
call Function1
End Sub

Function MyFunction1()
function code here
End Function

or
Sub Macro2()
dim MyVariable As String
MyVariable = MyFunction2
End Sub

Function MyFunction2() as String
MyFunction2 = "Hi"
End Function

or

Sub Macro3()
dim MyVariable As Integer
MyVariable = MyFunction3(4)
End Sub

Function MyFunction3(iVariable As Integer) as Integer
MyFunction3 = iVariable + 6
End Function

or

If the function is on a worksheet module then you will need to use the
full sheet name as well as the function name

eg
call Sheet1.Function1


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=522044