Hello everyone,
I believe this would be a very easy question for the experts here. I want to use variables from another sub/module. An example of the code in module 1 is below:
An example of code in module 2 is below:
The problem is the variable pinit, uy_from and uy_to are not recognized in module 2 sub. I tried to declare the variables as public (as shown above) but still, it is not working. I would appreciate the help from the forum
Thanks
I believe this would be a very easy question for the experts here. I want to use variables from another sub/module. An example of the code in module 1 is below:
Code:
Public pinit, uy_from, uy_to As Variant, ws As Worksheet
Sub TC()
pinit = InputBox("initials")
uy_from = InputBox("Year From")
uy_to = InputBox("Year To")
........ all the code is put here
End Sub
An example of code in module 2 is below:
Code:
Sub Analysis()
Workbooks(pinit & "_Data_Compiled_UY_" & uy_from & "_" & uy_to & ".xlsx").Activate
.............. all the code is here
End Sub
The problem is the variable pinit, uy_from and uy_to are not recognized in module 2 sub. I tried to declare the variables as public (as shown above) but still, it is not working. I would appreciate the help from the forum
Thanks
Last edited by a moderator: