EXCEL VBA使用msgbox显示combobox中的项目
第一:初始化用户窗体
我通过使用下面的代码初始化我的页面,以便它将填充我的combobox。
For Each cell In rangeA If cell.Value <> "" Then ComboBox1.AddItem cell.Value Else End If Next
下一个
我有一个button来提示一个msgbox,将调用我的combobox内的所有项目。 我该怎么做呢? 提前致谢。
这可以如下完成:
Private Sub ShowComboBoxAsMsgBox() Dim s As String Dim sep As String Dim i As Integer For i = 0 To Me.ComboBox1.ListCount - 1 s = s & sep & Me.ComboBox1.List(i) sep = vbCrLf Next i MsgBox s, vbInformation, "my ComboBox" End Sub