ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing variables from module to userform (https://www.excelbanter.com/excel-programming/283556-passing-variables-module-userform.html)

Chris Dunigan

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

patrick molloy

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
.


Tim Zych[_4_]

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




Jon Peltier[_4_]

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



Chris Dunigan

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!


All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com