Scenario:
I have 3 subs inModule 1.
Each one of thesesubs uses some but not all of 5 available variables. All Strings.
Instead of pickingand choosing which variables to define in each of the 3 subs, I'd like tocreate 1 more sub in Module 2. This sub would be called at the start of each ofthe 3 subs in Module 1 with the intent of defining all variables all the time.
Currently, it showsthat the the variable was defined, but it doesn't always translate into each ofmy other subs. I have message boxes in both the sub in Module 2 and the sub inModule 1 to show the variable's value during the run. Whenever the message boxin Module 1 runs, it doesn't always give me a value and is sometime blank.
Does anyone know whymy variables won't always translate from sub4 in Module 2 to a subs1-3 inModule 1 after sub4 is called? What's weird is that it started out NOT workingfor me, and then it started working, so I added more variables, and now it'sNOT working again for those added variable. It's like there's a time limit onwhen you add it or something, which doesn't make any sense to me.
If there's a betterway to do this, please let me know!
I have 3 subs inModule 1.
Each one of thesesubs uses some but not all of 5 available variables. All Strings.
Instead of pickingand choosing which variables to define in each of the 3 subs, I'd like tocreate 1 more sub in Module 2. This sub would be called at the start of each ofthe 3 subs in Module 1 with the intent of defining all variables all the time.
Currently, it showsthat the the variable was defined, but it doesn't always translate into each ofmy other subs. I have message boxes in both the sub in Module 2 and the sub inModule 1 to show the variable's value during the run. Whenever the message boxin Module 1 runs, it doesn't always give me a value and is sometime blank.
Does anyone know whymy variables won't always translate from sub4 in Module 2 to a subs1-3 inModule 1 after sub4 is called? What's weird is that it started out NOT workingfor me, and then it started working, so I added more variables, and now it'sNOT working again for those added variable. It's like there's a time limit onwhen you add it or something, which doesn't make any sense to me.
If there's a betterway to do this, please let me know!
Rich (BB code):
Rich (BB code):
'In Module 1
Public Sub one()
Call four
MsgBox (variable1)
MsgBox (variable2)
End Sub
Public Sub two()
Call Variables
MsgBox (variable1)
MsgBox (variable4)
End Sub
Public Sub three()
Call Variables
MsgBox (variable3)
MsgBox (variable5)
End Sub
'In Module 2
Public variable1 AsString
Public variable2 AsString
Public variable3 AsString
Public variable4 AsString
Public variable5 AsString
PublicSub four()
WithActiveWorkbook
'selects column C first
CurrRow = ActiveCell.Row
Range("C" & CurrRow).Select
variable1 = ActiveCell.Offset(0, -1).Value
variable2 = ActiveCell.Value
variable3 = ActiveCell.Offset(0, 1).Value
variable4 = ActiveCell.Offset(0, 2).Value
variable5 = ActiveCell.Offset(0, 3).Value
EndWith
EndSub