【发布时间】:2019-09-02 16:04:41
【问题描述】:
此代码仅在 ListBox 的最后一行显示“已确认”?关于如何为所有线路执行此操作的任何想法?
Private Sub CommandButton2_Click()
With ListBox1
For i = 1 To 200
If .List(1, 1) = "O/C" Then
.List(.ListCount - 1, 4) = "Confirmed"
End If
Next i
End With
End Sub
【问题讨论】:
-
假设你的意思是
For i = 0 to .ListCount-1,然后是If .List(i, 1) = "0/C" Then和.List(i, 4) = "Confirmed";考虑到 listindex 是零绑定的(以及列表中的列索引,因此通过指示.List(i,1)你会得到第二个列表 col 而 4 实际上是指第 5 个列表 col!)@Andy `
标签: excel vba listbox userform