View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Alan Alan is offline
external usenet poster
 
Posts: 188
Default can a userform pass an argument?

"Harald Staff" wrote in message
...

Hi Mike

I really dislike the use of public variables for those purposes, so
allow me to mention an alternative solution. Variables to be passed
to a Sub or Function are placed withinits parentheses:

Sub Test(S As String)
MsgBox "Someone passed " & S
End Sub

Now in your userform:

Private Sub CommandButton1_Click()
Call Test(Me.TextBox1.Text)
End Sub

HTH. Best wishes Harald


Hi Harald,

How about if the sub calls the userform (rather than the other way
around as you have shown above)?

What is the best practice way to pass a variable back to the calling
sub?

Thanks,

Alan.