ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   User Forms - Combo Boxes (https://www.excelbanter.com/excel-discussion-misc-queries/108249-user-forms-combo-boxes.html)

Michael Excel Dude

User Forms - Combo Boxes
 
I'm designing a user form with Combo Boxes/List Boxes. I have three related questions:

1. My combo box shows my list, but allows other input (other than the value of the lists). How can I restrict entry to the only the choices on the list?

2. I've set up my combo box with a reference to a range for the box values. How do I embed the list values directly in the code instead of a reference to cells?

3. When the user enters info in the various boxes of the user form, how can I show a cell/box within the user-form showing the result of a formula which uses the values entered in the form?

Any help would be appreciated.

Thanks!

Dave Peterson

User Forms - Combo Boxes
 
#1. Make the .style fmStyleDropDownList

#2. Use .additem

Private Sub UserForm_Initialize()

Dim iCtr As Long
With Me.ComboBox1
.Style = fmStyleDropDownList
For iCtr = 1 To 4
.AddItem "A" & iCtr
Next iCtr
End With

End Sub

#3. I wouldn't use the formula in the cell. I'd duplicate the formula in code
and just make sure everything is valid before trying to display the results.
And maybe put a button on the form to "Evaluate This Data" that updates a
Label????



Michael Excel Dude wrote:

I'm designing a user form with Combo Boxes/List Boxes. I have three
related questions:

1. My combo box shows my list, but allows other input (other than the
value of the lists). How can I restrict entry to the only the choices
on the list?

2. I've set up my combo box with a reference to a range for the box
values. How do I embed the list values directly in the code instead of
a reference to cells?

3. When the user enters info in the various boxes of the user form, how
can I show a cell/box within the user-form showing the result of a
formula which uses the values entered in the form?

Any help would be appreciated.

Thanks!

--
Michael Excel Dude


--

Dave Peterson

Michael Excel Dude

Thanks Dave, that worked great!

Quote:

Originally Posted by Dave Peterson
#1. Make the .style fmStyleDropDownList

#2. Use .additem

Private Sub UserForm_Initialize()

Dim iCtr As Long
With Me.ComboBox1
.Style = fmStyleDropDownList
For iCtr = 1 To 4
.AddItem "A" & iCtr
Next iCtr
End With

End Sub

#3. I wouldn't use the formula in the cell. I'd duplicate the formula in code
and just make sure everything is valid before trying to display the results.
And maybe put a button on the form to "Evaluate This Data" that updates a
Label????



Michael Excel Dude wrote:

I'm designing a user form with Combo Boxes/List Boxes. I have three
related questions:

1. My combo box shows my list, but allows other input (other than the
value of the lists). How can I restrict entry to the only the choices
on the list?

2. I've set up my combo box with a reference to a range for the box
values. How do I embed the list values directly in the code instead of
a reference to cells?

3. When the user enters info in the various boxes of the user form, how
can I show a cell/box within the user-form showing the result of a
formula which uses the values entered in the form?

Any help would be appreciated.

Thanks!

--
Michael Excel Dude


--

Dave Peterson



All times are GMT +1. The time now is 03:51 AM.

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