Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing variables from module to userform
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing variables from module to userform
Add a listbox to the form
to populate it For Index = 1 to 100 '''OR '''For Index = lbound(MyArray,1) to ubound(MyArray,1) Listbox1.AddItem MyArray(index) next set the listbox ListStyle property to frmListStyleOption Patrick Molloy Microsoft Excel MVP -----Original Message----- 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 . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing variables from module to userform
Another way to fill a listbox:
UserForm1.ListBox1.List() = arr() "Chris Dunigan" wrote in message om... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing variables from module to userform
Thanks guys,
It was a very simple problem of not declaring a public variable, therefore the code couldn't pick up the macro values. I was obviously not all there yesterday!! Thanks again, Chris *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA - passing Variables to subroutines | Excel Discussion (Misc queries) | |||
Passing Variables | Excel Discussion (Misc queries) | |||
VBA passing variables through a function | Excel Discussion (Misc queries) | |||
Passing Variables | Excel Programming | |||
Passing a value to a variable from Userform | Excel Programming |