【发布时间】:2017-11-18 09:05:14
【问题描述】:
VBA 新手,在从 ListBox 中获取选定项目时遇到一些困难。我在 For 行上不断收到错误消息。 ListBox 的名称是正确的,我认为 .ListCount 应该可以工作。
Sub GetListBox1()
Dim SelectedItems As String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected = True Then
SelectedItems = SelectedItems & ListBox1.List(i)
End If
Next i
Debug.Print SelectedItems
End Sub
【问题讨论】:
-
此代码
Sub GetListBox1位于何处?它在User_form模块内吗?什么功能或控件触发它?
标签: excel vba listbox userform