Excel 从第二列填充ListView
我从excel范围填充listview,listview从第二列而不是第一列填充 是否有需要为此检查的选项 我的代码如下:Excel 从第二列填充ListView,excel,vba,Excel,Vba,我从excel范围填充listview,listview从第二列而不是第一列填充 是否有需要为此检查的选项 我的代码如下: Dim sh Dim LR Dim lC Dim r With LVIV .View = lvwReport .FullRowSelect = True .Gridlines = True .CheckBoxes = False With .ColumnHeaders .Clear '.Add , , "#", 2
Dim sh
Dim LR
Dim lC
Dim r
With LVIV
.View = lvwReport
.FullRowSelect = True
.Gridlines = True
.CheckBoxes = False
With .ColumnHeaders
.Clear
'.Add , , "#", 20
.Add , , "Language", 70
.Add , , "Time", 70
.Add , , "Date", 70
.Add , , "Team", 70
.Add , , "HO #", 70
.Add , , "Case Worker", 80
.Add , , "Interpreter", 80
.Add , , "Room", 30
.Add , , "Applicant", 70
.Add , , "Interpreter", 70
.Add , , "Messaged DM", 70
.Add , , "IV Start Time", 70
.Add , , "Status", 70
End With
Dim li As ListItem
Set sh = ThisWorkbook.Worksheets(4)
With sh
LR = .Range("A" & .Rows.Count).End(xlUp).row
End With
lC = 0
For r = 2 To LR
If Left(sh.Cells(r, 6), 10) = "04/06/2019" Then
Set li = .ListItems.Add()
li.ListSubItems.Add , , sh.Cells(r, 4).Value
li.ListSubItems.Add , , sh.Cells(r, 7).Value
li.ListSubItems.Add , , sh.Cells(r, 6).Value
li.ListSubItems.Add , , sh.Cells(r, 13).Value
li.ListSubItems.Add , , sh.Cells(r, 2).Value
li.ListSubItems.Add , , sh.Cells(r, 1).Value
li.ListSubItems.Add , , sh.Cells(r, 5).Value
li.ListSubItems.Add , , sh.Cells(r, 23).Value
''
li.ListSubItems.Add , , sh.Cells(r, 13).Value
li.ListSubItems.Add , , sh.Cells(r, 2).Value
li.ListSubItems.Add , , sh.Cells(r, 1).Value
li.ListSubItems.Add , , sh.Cells(r, 5).Value
li.ListSubItems.Add , , sh.Cells(r, 23).Value
End If
Next
End With
我已尝试创建一个新的listview以获取默认选项,但仍然是一样的。因此,基于我在a中共享的相同选项,这应该可以工作:
'First bit of code....
Set li = .ListItems.Add(, , sh.Cells(r, 4).Value)
li.ListSubItems.Add , , sh.Cells(r, 7).Value
li.ListSubItems.Add , , sh.Cells(r, 6).Value
li.ListSubItems.Add , , sh.Cells(r, 13).Value
'Continue your code....
这可能与上一个问题相同
Set li=.ListItems.Add(,sh.Cells(r,4.Value)
可能会起作用。下面继续从li.ListSubItems.Add,sh.Cells(r,7).Value
开始。现在你的第一个专栏里什么都没有。非常感谢,我缺少的是花括号