View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Kevin Beckham Kevin Beckham is offline
external usenet poster
 
Posts: 78
Default Using Sub-procedures w/in a function

Either define the variable at a global level, e.g.
Option Explicit
Dim myVar1 as Integer 'can be used by any Sub or
Function on this sheet, retains its value between uses
Public myVar2 as Integer 'can be used by any Sub or
Function in this project, retains its value between uses

:
:

else define the varibale as static within the function,
e.g.

Function TestIt() As Integer
Static myVar3 As Integer
myVar3 = InputBox("Enter a number", "Test it", myVar3)
TestIt = myVar3
End Function

then type
?Testit
in the Immediate pane a couple of times (Ctrl-G if it's
not open)

Kevin Beckham


-----Original Message-----
Is it possible to use a subprocedure within a function?
How would you refer to the subprocedure?

I'm trying to create a variable in a subprocedure that is
updated w/ a function, so that the vairable holds the
value and can be used the next time the function is

called
upon.

Any help would be greatly appreciated!
.