Here is an example of how I created a variable in one sub and used it in another:
Private Sub txtLastName_LostFocus() FirstName = Me.txtFirstName.Value LastName = Me.txtLastName.Value FullName = FirstName & " " & LastName sayHelloToTheUser (FullName) End Sub Private Sub sayHelloToTheUser(name As String) MsgBox "Hello " & name End Sub
Essentially, you should pass it using another sub and require the necessary arguments. This is the main way to pass arguments through.
source share