View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Pass Variable to another Sub

There might be a more sophisticated way, but the way that I do it is:

Macro1: Worksheets(1).Range("IV65535") = myVar
Macro2: myVar = Worksheets(1).Value

Place the value of your variable some place on a worksheet that will not
interfere with your code, calculations, additions or deletions. Remember
that if you use
the UsedRange constant that it will incorporate the cell with that value.
If you are the sole user of the workbook, you could use a different sheet
than the one your primary data base is on. But there might be a better way.

"CSUS_CE_Student" wrote:

Hey everyone, i need some help. I am trying to pass a variable to another
sub. I will need to pass 3-4 variables total, so if my example wont allllow
for this please let me know what i need to do. I did look at other posts
but was not able to find something that worked ( or i didnt know it would).
Im not that knowegable in programing.

Sub Wall()
Dim WallEl As Single
WallEl = Range("a1").Value
End Sub

Sub NextWall()
Range("a2") = WallEl
End Sub


Thanks for your help in advance

jared