Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA Function Parameter Overwritten
I have two vba functions in an excel macro, where the result of th
first is passed into the other as a parameter. The problem is that th value of this paramter appears to be changed by the actions of thi second function, hence overwritting the value of my first function result. To illustrate: Dim a, b As Integer a = funcone(0,"Hello") b = functwo(a,"Hello") FUNCTION DEFINITIONS Function funcone(pos As Integer, text As String) As Integer Dim pos As Integer 'Some tasks obtaining pos funcone = pos End Function Function functwo(pos As Integer, text As String) As Integer For pos = 1 To 10 'Some tasks Next pos functwo = pos + 30 End Function By using the basics of the functions above, a = 10 always. Why Tracing the values of a and b. a = funcone(0,"Hello") 'a = 5 for example b = functwo(a,"Hello") 'a = 10 'b = 40 This is driving me crazy so any help will be greatly appreciated -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 named ranges - how to use as function parameter? | Excel Discussion (Misc queries) | |||
Excel 2007 Data -- SQL Server proc or function with parameter | Excel Discussion (Misc queries) | |||
use function to change a string to function's parameter | Excel Worksheet Functions | |||
Unknown IF function parameter on amortization schedule | Excel Worksheet Functions | |||
Function parameter description | Excel Programming |