Public sp As Worksheet // on top of ThisWorkbook module
...
Sub one()
Set sp = Sheets("blueSky") // marked
MsgBox sp.Name
...
Sub two()
Set sp = Sheets("blueSky") // marked
MsgBox sp.Range("A1").Value
Marked line is allways the same.
So, is it possible to write the marked line only once – and where ?
I tried on Workbook.Open event – without result
I want in each Sub write only the third line – which is allways different.
If you put the followin in a module (not
ThisWorkbook) you get a globalWorksheetvariable:You can then adress it in any of the following ways in
ThisWorkbook(subsone()andtwo()will also work in a module):