View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Using Public to Pass Variable

Take the declaration our of the sub. It should stand alone at teh top of the
module...

HTH

"D.Parker" wrote:

I have declared the declarations in a regular code module (i.e. Module2) and
have taken them out of the UserForm, and unfortunately my message Boxes are
still empty. Am I declaring the variable wrong?

Public Sub VariableDeclarations()

Public XName As String

End Sub

If someone could provide the exact code it would be appreciated. I am very
new to the VBA Excel world. Thanks again.

D.Parker
_________________________________
"Chip Pearson" wrote:

First of all, I would avoid using "Name" as the variable name, as
this is a property name of many objects; using "Name" will cause
confusion. Don't declare the Public variable in the userform's
module. Declare it in a regular code module instead.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"D.Parker" wrote in message
...
I have a UserForm that captures the users name, I am trying to
pass that
information to another UserForm. I'm assuming that is possible
using the
Public declarations, but I am obviously having problems. Here
is my example
code

Public Name As String
________________________________
Private Sub OKButton_Click()
Name = NameBox1

UserForm4.Hide
End Sub
________________________________

'Name gets passed to this UserForm

________________________________
Private Sub SignOffButton_Click()
MsgBox Name

Unload UserForm5
End Sub
________________________________

Do I need to declare the variables Public in UserForm5 also?
Are they
declared in the right place? Should the subs be name Public
instead of
Private? etc. My MsgBox is returning empty. Any help is
greatly
appreciated.

DP