假设我有一系列的值:
Customer | Services | Cost | Paid
Mel | Abc | $1.00 | TRUE
Mel | Def | $2.00 | FALSE
Xin | Abc | $3.00 | TRUE
Titus | EEE | $4.00 | TRUE我希望将这些项插入到列表框中。然而,我有几个标准,那就是只显示特定于用户的项目(例如Mel或Xin或Titus),并且仅在"False“时显示。我该怎么做呢,提前谢谢你。
我现在所拥有的:
Dim lbtarget As MSForms.ListBox
Dim rngSource As Range
Set rngSource = Range("Table1")
Set lbtarget = Me.ListBox1
With lbtarget
'Determine number of columns
.ColumnCount = 4
'Set column widths
.ColumnWidths = "50;80;100"
'Insert the range of data supplied
.List = rngSource.Cells.Value
End With发布于 2011-02-23 17:37:31
替换
.List = rngSource.Cells.Value使用
For Each rw In rngSource.Rows
If rw.Cells(1,1) = <Specify User> And rw.Cells(1,4) = FALSE Then
.AddItem ""
For i = 1 To .ColumnCount
.List(.ListCount - 1, i - 1) = rw.Value2(1, i)
Next
End If
Next使用Mel作为用户的整个子对象
Private Sub CommandButton1_Click()
Dim lbtarget As MSForms.ListBox
Dim rngSource As Range
Dim rw As Range
Dim i As Long
Set rngSource = Range("Table1")
Set lbtarget = Me.ListBox1
With lbtarget
.ColumnCount = 4
.ColumnWidths = "50;80;100"
For Each rw In rngSource.Rows
If rw.Cells(1, 1) = "Mel" And rw.Cells(1, 4) = False Then
.AddItem ""
For i = 1 To .ColumnCount
.List(.ListCount - 1, i - 1) = rw.Cells(1, i)
Next
End If
Next
End With
End Subhttps://stackoverflow.com/questions/5088787
复制相似问题