Creating a Dropdown menu in VBA associated with a Command Button

JoeC00l24

New Member
Joined
Nov 19, 2014
Messages
1
Hello,

I have created a command button that i want to collect different pieces of information. I have figured out how to do so with an InputBox. The issue i am facing is that i would like the user to have a dropdown box to input the information instead of typing it into the inputbox. This would guarantee that some of the inputs will stay constant for sorting the data at a later time(example First, Second, Third Shift). I have attached my code so far.

Private Sub CommandButton1_Click()
Dim RowHolder As Integer
Dim OperatorID As Variant
Dim JobnumberID As Variant
Dim ShiftID As Variant
Dim MachineID As Variant
Dim QuantityID As Variant
Dim DefectID As Variant
RowHolder = 1

OperatorID = InputBox("Enter Employee ID")
Do Until (IsEmpty(Cells(RowHolder, 2)))
RowHolder = RowHolder + 1
Loop
ShiftID = InputBox("Select Shift")
JobnumberID = InputBox("Enter Job Number")
MachineID = InputBox("Enter Machine ID Number")
QuantityID = InputBox("Enter Number of Scrapped Parts")
DefectID = InputBox("Reason for scrapping parts")

Range("B" & RowHolder).Value = OperatorID
Range("C" & RowHolder).Value = ShiftID
Range("D" & RowHolder).Value = JobnumberID
Range("E" & RowHolder).Value = MachineID
Range("F" & RowHolder).Value = QuantityID
Range("G" & RowHolder).Value = DefectID
End Sub

Thanks,
Joe
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hello,

the only solution I can think of is to use a userform with combobox, where the RowSource are the cells where the data is. If you have a Command button you can then have code to get the chosen text values out.
 
Upvote 0

Forum statistics

Threads
1,225,227
Messages
6,183,692
Members
453,180
Latest member
Systemize

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