Questions on passng data between UserForm, Module

  • Thread starter Dennis Benjamin
  • Start date
D

Dennis Benjamin

Hey All

I'm new to VBA and just getting the hang of it. Would appreciate any help on
the following, where I'm a bit confused about namespaces.

I've written a bunch of code and now need to use a Userform to get input,
specifically values for two variables nAliquots and vAliquots. I'm using a
TextBox, and the only way I could pass the values back to my module (stored
in thisWorkBook) is like so:

Private Sub OK_Click()
ThisWorkbook.GetAliquotValues
Unload Me
End Sub

Where the GetAliquotValues routine pulls the values stored in the TextBox.
It seems kludgy to me to have to call a function back in the WorkBook - I'd
like to be able to do something like

Private Sub OK_Click()
nAliquots = me.TextBox1.Value
vAliquots = me.TextBox2.Value
Unload Me
End Sub

And have the variables in the Workbook loaded w/ the users data. I declared
nAliquots and vAliquots as Public but it didn't work.


So.... is there a straightforward way to share variables between UserForms
and Modules? Or am I thinking about this incorrectly?

Thanks!
 
M

Mike Fogleman

Where exactly are they declared? I declare my Public variables at the very
top of a general module (or right under Option Explicit) outside of, and
before any subs, functions, or procedures.

Mike F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top