VBA Macro InputBox to display dropdown opposed to entering text?

Johnnyboy1x

New Member
Joined
Jan 11, 2013
Messages
32
Hello All --

I have a macro button in my spreadsheet that initiates various input boxes and places input in specific cells

I am running Excel 2016, WIN 7 64-bit

I know the line in my code below starting with DROPDOWNBOX is not right, but that is the best way I can express what I am trying to do.

Hopefully someone can help!

Thank you in advance, Johnny


Code:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = InputBox("Enter Serial Number (ex. 142110/16)")
Range("H13").Value = myValue
myValue = InputBox("Enter Your Name (ex. Bill Smith)")
Range("H15").Value = myValue
myValue = InputBox("Job Code  ex. PD,PM,FS,FLEX,WTY, INST")
DROPDOWNBOX Job Code = Array("PD", "PM", "FS", "WTY", "FLX", "INST", "Non Billable")
Range("H14").Value = myValue
End Sub
 
Pretty sure you can't have a dropdown on a input box. You may need to create a basic userform and call that.

Hello sericom and alpha frog --

I found success! Thanks for all the support.

At the end this is my code...I created another sheet and named it 'combo boxes'. entered values in a1-a2 and then highlighted a1-a2 and defined it as job status. Next, enters values in b1-b7 and highlighted b1-b7 and defined it as job code

Macro Button on sheet1 one calls userform.

Macro Button
Code:
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
[code/]

This is the user form code

[code]
Private Sub ComboBox1_Change()

End Sub

Private Sub ComboBox2_Change()

End Sub

Private Sub CommandButton1_Click()
    Sheets("Service Report").Range("H15") = TextBox1.Value
    Sheets("Service Report").Range("H13") = TextBox2.Value
    Sheets("Service Report").Range("B13") = TextBox3.Value
    Sheets("Service Report").Range("H14") = ComboBox1.Value
    Sheets("Service Report").Range("B17") = ComboBox2.Value
MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"



End Sub


Private Sub CommandButton2_Click()
Unload Me
End Sub
[code/]

THANKS AGAIN!  Johnny
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,225,226
Messages
6,183,688
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