Help With A Variable And Functions
I would add an argument to and pass MyValue to the MySubThatChangesMyValue
subroutine ByRef so that changes it makes are reflected back to the calling
program.
Public Sub MyMainFunction()
MyValue = 10
Call MySubThatChangesMyValue(MyValue)
......more processing that relies on the changed MyValue...
End Sub
Sub MySubThatChangesMyValue(ByRef VariableIn As Double)
....some code that changes MyValue....
End Sub
I made a guess at the data type for MyValue as Double, but you can change it
to match your declaration back in MyMainFunction (you do declare your
variable as to data type, right?).
--
Rick (MVP - Excel)
"Andy" wrote in message
...
Hi Gang
I need some help with variables with functions. I've got a main
function that does some processing with a variable MyValue. I need to
create a sub function that changes the value of MyValue so that when
the sub function is done the main function knows what the new value of
MyValue is. How do I do this???
Please help,
Andy
Public Sub MyMainFunction()
MyValue = 10
Call MySubThatChangesMyValue
...more processing that relies on the changed MyValue...
End Sub
------------------------------------------------
Sub MySubThatChangesMyValue()
...some code that changes MyValue....
End Sub
|