VBA – 列表框删除所有select和下一步全选

有人可以告诉我为什么这段代码不会读代码中的第一个。 我试图删除我手动select的列表上的所有项目,这是工作,但之后,我希望它select所有我可以写一个工作表的洞列表,但不pipe我做什么我可以'在我从列表中删除项目后,将其全部选中。 事实上,它不会读取第一个下一个我怎么知道,因为如果我设置清除function之前,它将清除工作表,但不是如果我把它放在下一个代码之后。

Private Sub CommandButton2_Click() For listIndexCount = 0 To ListBox1.ListCount If listIndexCount >= ListBox1.ListCount Then Exit Sub End If If ListBox1.Selected(listIndexCount) Then ListBox1.RemoveItem (listIndexCount) listIndexCount = listIndexCount - 1 End If Next listIndexCount Sheets("Courses_calc").Cells.Clear For i = 0 To ListBox1.ListCount - 1 ListBox1.Selected(i) = True Next i End Sub