Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Questions on passng data between UserForm, Module

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!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Questions on passng data between UserForm, Module

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
"Dennis Benjamin" wrote in message
...
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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
call Module from MS Excel Object - Probably very easy VB questions Kevin Excel Discussion (Misc queries) 4 January 4th 08 02:32 AM
Userform/Module saziz[_16_] Excel Programming 3 October 17th 05 12:14 AM
data entry with userform questions mbernardi Excel Programming 0 September 24th 04 02:06 AM
Passing variables from module to userform Chris Dunigan Excel Programming 4 November 26th 03 09:37 AM
Delete userform/module using VB Rohit Thomas Excel Programming 5 July 16th 03 11:01 PM


All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"