Passing Variables to another macro
Option Explicit
Sub Main()
Dim icntr As Long
Dim adjNum As Long
For icntr = 1 To 10
MySub icntr
adjNum = MyFunc(icntr)
MsgBox "Adjusted Counter is " & adjNum
Next
End Sub
Sub MySub(num As Long)
If num < 5 Then
MsgBox "num: " & num & ", is less than 5"
Else
MsgBox "num: " & num & ", is greater" & _
" than or equal to 5"
End If
End Sub
Function MyFunc(myNum As Long)
Dim MyAdjustedNum As Long
MyAdjustedNum = myNum * myNum
MyFunc = MyAdjustedNum
End Function
--
Regards,
Tom Ogilvy
"Jeff" wrote in message
...
I am trying to modularize my code, but I'm having trouble with one aspect.
How do I make a variable such as a counter available within a macro that I
just called?
|