I have a module which runs a subroutine and some variables are defined within this subroutine. I also have the variables set as Public before the Sub MACRO() line. The routine runs, and then another sub-macro is called within this one which will use the variables as defined from the previous macro. When the sub-macro runs, it doesn't seem to carry forward the values for the variables that were defined in the previous macro! Hopefully that sort of made sense but here's an example to illustrate what I mean
EG
Public MONTHI as Integer
Public YEARI as Integer
Public YEARS as String
Public MONTHS as String
Sub MyMacro()
For MONTHI = 1 to 12
For YEARI = 85 to 86
MONTHS = MONTHI
YEARS = YEARI
......
PARTTWO
Next MONTHI
Next YEARI
End Sub
Sub PARTTWO()
Workbooks.Open Filename = "ABC" & YEARS & ".xls"
End Sub
So when it goes to open ABC for the current year the macro is working on, the YEARS variable is empty.
Thanks in advance!
EG
Public MONTHI as Integer
Public YEARI as Integer
Public YEARS as String
Public MONTHS as String
Sub MyMacro()
For MONTHI = 1 to 12
For YEARI = 85 to 86
MONTHS = MONTHI
YEARS = YEARI
......
PARTTWO
Next MONTHI
Next YEARI
End Sub
Sub PARTTWO()
Workbooks.Open Filename = "ABC" & YEARS & ".xls"
End Sub
So when it goes to open ABC for the current year the macro is working on, the YEARS variable is empty.
Thanks in advance!