View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ManualMan ManualMan is offline
external usenet poster
 
Posts: 35
Default Returning a variable from a sub

Hi, you can do this by first Publicly declaring your variable
(otherwise a variable will only be know inside the sub

Public TestPoint

Sub Large()
Small 'runs the sub named small
MsgBox TestPoint
End Sub

Sub Small()
TestPoint = 100
End Sub

The other method is passing a variable to another sub with arguments

Sub Small(Testpoint As Long) 'calls the passed variable "Testpoint"
MsgBox(TestPoint)
End Sub

Sub Large()
Small(100) 'pass the value 100 to the sub Small
End Sub

Regards,
ManualMan
http://www.gamesXL.tk