LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Excel 2007 named ranges - how to use as function parameter? Gershon Excel Discussion (Misc queries) 3 May 12th 10 08:27 PM
Excel 2007 Data -- SQL Server proc or function with parameter lm Excel Discussion (Misc queries) 1 August 21st 09 10:49 PM
use function to change a string to function's parameter ViestaWu Excel Worksheet Functions 3 November 21st 07 12:42 PM
Unknown IF function parameter on amortization schedule Michael from Austin Excel Worksheet Functions 1 November 9th 04 06:32 PM
Function parameter description Christine[_5_] Excel Programming 1 November 27th 03 06:08 PM


All times are GMT +1. The time now is 09:28 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"