LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default Return value in "Sub"

Hi,

I was trying to figure out how to return a value from a "Sub" procedure. I
understand that if you write a function you can set a value equal to that
function and that will return the value. For example

Public Function TestFunction(iVal as integer)
(
TestFunction = iVal * iVal
)

Var = TestFunction(4) ' will return 4 * 4 to the variable "Var"

But in a Sub

Sub TestSub(iVal as integer)
(
TestSub = iVal * iVal
)

Call TestSub

Does not work. I dont want to use functions because I cannot do as much as
in a sub and this is just a simple example, I forget the rules but I dont
think you can edit ranges or edit objects.
 
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
function to return day in the form "Monday", "Tuesday" etc given . MTro Excel Worksheet Functions 2 October 3rd 07 09:49 AM
Check if cells contain the word "Thailand", return "TRUE" ali Excel Worksheet Functions 7 September 14th 07 09:53 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
If (A1 = "ValueA" & C1 = "ValueB") return the quantity of matches DaveC Excel Discussion (Misc queries) 2 July 1st 07 10:34 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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

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

About Us

"It's about Microsoft Excel"