![]() |
Returning a variable from a sub
hello there! Is there a way to either return a value from a sub to b used in another sub OR is there a way to call a value from another sub My sample code below: Sub Small() TestPoint = 100 End Sub Sub Large() Dim TestPoint |
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 |
All times are GMT +1. The time now is 07:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com