Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
call Module from MS Excel Object - Probably very easy VB questions | Excel Discussion (Misc queries) | |||
Userform/Module | Excel Programming | |||
data entry with userform questions | Excel Programming | |||
Passing variables from module to userform | Excel Programming | |||
Delete userform/module using VB | Excel Programming |