drop down menu in vba form

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I want to create a form which has 2 text boxes for First Name and Last name and one drop down menu which has Year of Birth, so user would enter First, Last and Year of birth and then excel copy that to excel. I know how to do the Text boxes, but not sure if I can do the Drop down menu.
Is it doable? Thank you.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You said:
I want to create a form

Do you mean a UserForm?

You said:
and one drop down menu

Do you mean Combobox?

You said:
and then excel copy that to excel

Copy the values in the two textboxes and the Combobox and paste where?

Excel has a lot of places.
 
Upvote 0
Sorry I was not clear. Yes UserForm. Combobox is fine to me if I can select year from it. The UserForm would have "Enter" button. If user pressed Enter then FistName, LastName, Year of birth will go to A1, B1, C1 if row 1 was empty otherwise they will go to A2, B2 and C2.
Thanks
 
Upvote 0
Assuming you have a Textbox named Textbox1 and Textbox2
These are default names

And a Combobox named Combobox1

And a command button named CommandButton1

Try this:

Put these scripts in your Userform
Code:
Private Sub CommandButton1_Click()
'Modified  8/22/2018  12:12:01 PM  EDT
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(Lastrow, 1).Value = TextBox1.Value
Cells(Lastrow, 2).Value = TextBox2.Value
Cells(Lastrow, 3).Value = ComboBox1.Value
End Sub
Private Sub UserForm_Initialize()
Dim i As Long
Dim x As Long
x = "2010"
For i = 1 To 15
ComboBox1.AddItem x + i
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,607
Members
449,174
Latest member
ExcelfromGermany

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top