Good Afternoon,
I am having some trouble getting something to work. The below code works flawlessly if they are all in the same module. However what I am trying to do is to have the subs for Module 2-4 be in separate modules. But still update the global variable (ShtName) in the sub DispShtName. I have tried adding the Public Shtname As String to the top of every module but it only returns blanks. The full code has over 50 different modules that are 150 rows+ so do not want to have them all on one module. Any help would be more than appreciated!
I am having some trouble getting something to work. The below code works flawlessly if they are all in the same module. However what I am trying to do is to have the subs for Module 2-4 be in separate modules. But still update the global variable (ShtName) in the sub DispShtName. I have tried adding the Public Shtname As String to the top of every module but it only returns blanks. The full code has over 50 different modules that are 150 rows+ so do not want to have them all on one module. Any help would be more than appreciated!
Code:
Public ShtName As String
Sub DispShtname()
Call Module2
MsgBox (ShtName)
Call Module3
MsgBox (ShtName)
Call Module4
MsgBox (ShtName)
End Sub
'*****************************************************************
Sub Module2()
ShtName = Sheets("Contact List").Range("A5").Value
End Sub
'*****************************************************************
Sub Module3()
ShtName = Sheets("Contact List").Range("A6").Value
End Sub
'*****************************************************************
Sub Module4()
ShtName = Sheets("Contact List").Range("A7").Value
End Sub