View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier[_4_] Jon Peltier[_4_] is offline
external usenet poster
 
Posts: 90
Default Passing variables from module to userform

Chris -

The problem might be more basic (no pun) than Tim or Patrick have
addressed. The beginning user types

UserForm1.Show

And then wonders how to get information into the form and out of it. At
least this is where I once stumbled.

You should first load the form but not show it, then populate the
various controls as Tim and Patrick describe, then show it. When the
user closes the form, make sure the button code hides it, so it's still
in memory and the main procedure can get the information out. Then if
desired, the main sub can unload the form.

....
Load UserForm1
With UserForm1
' Populate the form's controls
.TextBox1.Text = myValue

' Show the form
.Show

' Extract from the form
myNewValue = .TextBox1.Text
End With
Unload UserForm1
....

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______


Chris Dunigan wrote:

Wonder if anyone can help me.

I have an array set up which collects string values. (100 in all)

I'd like to use these values in a userform, but can't work out a way
of getting these values from my code into the userform.

Basically i'd like a form which has the values collected from the
array to be displayed down the left hand side of the form, with a
tick-box to the right of them.

Hope this makes sense to some of you!

Thanks,
Chris