Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
GetOpenFilename not returning a usable variable | Excel Discussion (Misc queries) | |||
variable height variable width stacked bar charts | Charts and Charting in Excel | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
Cells.Find error Object variable or With block variable not set | Excel Programming |