I am relatively new to world of vba, but have been working with it quite intensively over recent months learning as I go.

I recently discovered that I don't need to dim my objects and variables at the beginning of each sub and can do this once at the top of the module or form code. I wanted to extend this further and set regular variables once per module (or even better once for whole workbook (if possible).

Below is example of a variable I am regularly using (pmtName) and I show the context I am using it in (Msg box Title), at the moment I define this in each sub exactly the same, but if I could just do this once or once per module/form that would be big improvement.

Any guidance would be greatly appreciated.

Option Explicit
Dim helperSheet as Worksheet, pmtName as String


Private Sub cmdSelect_Click()
     Set helperSheet = Sheets("helper")
     pmtName = helperSheet.Range("pmt_name")
     
     If ListBox1.ListIndex = -1 Then
        MsgBox "No project selected" & vbNewLine & vbNewLine & "Please select a project", vbOKOnly, pmtName
        Exit Sub
    End If

'Rest of code...

End Sub