ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm howto? (https://www.excelbanter.com/excel-programming/351734-userform-howto.html)

AMK4[_24_]

UserForm howto?
 

Task: I need to write a macro that grabs a particular Range and generate
a userform with a combobox.

Description:
Sheet1 contains names in cells D4:D34
Sheet2 has an action button which when clicked needs to:
- read the names in the afore mentioned range
- generate a pop-up userform that contains the list of names
in a combo box

From there, the user picks a name and hits an Okay (or other button)
which will then use their selection to perform some action.

I've been reading up on creating userforms, but I'm having a hard time
trying to figure out how to create something based on fluid data.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=506121


Rick Hansen

UserForm howto?
 
Hello AMK4,

There is several ways to attack you problem. But propably the easiest way.
First Insert a UserForm, from VB Editor. Then on the UserForm place
Combobox or or ListBox. In my example I use a ComboBox and name it
'cbox_Name'. Also add the CommandButton to the UserForm. Now place the
following code under the "UserForm_Initialize()" event. This code load
comboBox with the names on Sheet1, cells D4:D34. This event is execute
prior to showing the UserForm. I hope this gives you a starting point. For
your UserForm...

Rick, freezen in Alaska




Private Sub UserForm_Initialize()
Dim ws1 As Worksheet
Dim x As Integer

Set ws1 = Worksheets("Sheet1")

Me.cbox_Name.Clear
Me.cbox_Name.RowSource = ""

For x = 4 To 34
Me.cbox_Name.AddItem ws1.Cells(x, "D").Value
Next x


End Sub


"AMK4" wrote in message
...

Task: I need to write a macro that grabs a particular Range and generate
a userform with a combobox.

Description:
Sheet1 contains names in cells D4:D34
Sheet2 has an action button which when clicked needs to:
- read the names in the afore mentioned range
- generate a pop-up userform that contains the list of names
in a combo box

From there, the user picks a name and hits an Okay (or other button)
which will then use their selection to perform some action.

I've been reading up on creating userforms, but I'm having a hard time
trying to figure out how to create something based on fluid data.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:

http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=506121





All times are GMT +1. The time now is 11:45 AM.

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