Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
GetOpenFilename not returning a usable variable Lilivati Excel Discussion (Misc queries) 2 June 26th 06 09:02 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"