在input框中创build下拉列表

我正在为我们的团队创build一个任务列表,并input创buildinput框的新任务。 在“部门问题”中只有5个部门应该input。为防止人们input错误的部门名称,我想使用该input框的下拉列表。

我search了networking,但无法find如何在input框中创build一个下拉列表。 我不知道这是可能的吗?

谁能帮我?

我为input写的代码如下:

Private Sub Newaction_Click() Dim content As String, date1 As Date, date2 As Date, department As String Sheets("DO NOT DELETE").Rows("30:30").Copy Rows("14:14").Select Range("C14").Activate Selection.Insert Shift:=xlDown content = InputBox("describe the task") Range("C14").Value = content department = InputBox("to which department is the task assigned? ") '<-- here i want to create drop down list Range("D14").Value = department date1 = InputBox("when does the task start") Range("F14").Value = date1 date2 = InputBox("when should the task be finished? ") Range("G14").Value = date2 End Sub 

我在Excel中创build了一个表单,而不是使用input框。 为了select部门我创build了一个combobox与正确的部门:

 Private Sub Newaction_Click() Sheets("DO NOT DELETE").Rows("30:30").Copy Rows("14:14").Select Range("C14").Activate Selection.Insert Shift:=xlDown Cells(14, 3) = Taskd.Value Cells(14, 5) = ComboBox1 Unload Me UserForm2.Show End Sub Private Sub UserForm_Initialize() Taskd.Value = "" With ComboBox1 .AddItem "Lean" .AddItem "Maintenance" .AddItem "Process Engineering" .AddItem "Safety" .AddItem "Workinstructions" End With End Sub 

对于我创build一个单独的窗体(userfrom2和userform3)的date来inputcalander上的date。

 Private Sub MonthView1_DateClick(ByVal DateClicked As Date) On Error Resume Next startd = DateClicked Cells(14, 6).Value = startd Unload Me UserForm3.Show End Sub Private Sub MonthView1_DateClick(ByVal DateClicked As Date) On Error Resume Next endd = DateClicked Cells(14, 7).Value = endd Unload Me End Sub 

Monthview1是Excel中的一个额外选项,您可以通过以下方式进行激活:表单工具箱 – >右键单击工具箱 – >select其他控件 – > Microsoft Monthviews控件