Im trying to pass a string from a userform textbox to a public variable defined in a module. Cant for the life of me figure out whats happening. My code looks like this:
Module code
Userform codeOption Explicit Public test As String Sub btn_showuserform() userform1.Show MsgBox test End Sub
For some strange reason it works if I show the message box. But If i dont show the messagebox the value isnt passing to the variable??Option Explicit Sub btnOk_Click() test = userformtextbox.Value Unload Me End Sub
Also if i dont show the messge box but run the code from within in the userform code, the value does pass??