View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Passing variables back to main procedure

Matt,

try passing it by reference to the called sub.. For example:

Sub Main()
Dim i As Integer
i = 1
Increment i
Debug.Print i
End Sub

Sub Increment(ByRef x As Integer)
x = x + 1
End Sub



--
Hope that helps.

Vergel Adriano


"Matt McQueen" wrote:

I've a subroutine that calls another and passes a variable to it. However
within the 'called' sub is a variable that I would like to pass back to the
main sub. I know that this could be accomplished using module-level
variables, but I'd like to know how to pass a variable 'backwards'.

Cheers.