【问题标题】:VBA Listbox column to display alternative textVBA Listbox 列显示替代文本
【发布时间】: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


【解决方案1】:

不会有这样的工作:

.AddItem Worksheets(TextBox3.Value).Range("B" & i + 5).Value
            .List(.ListCount - 1, 1) = fnd.Offset(i + 3, 0)
            If .List(1, 1) = "Y" Then
                .List(.ListCount - 1, 2) = "Confirmed"
            End if

【讨论】:

    猜你喜欢
    • 2011-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多