我从excel范围填充列表视图,并且列表视图从第二列而不是第一列填充。
是否有需要对此进行检查的选项?
我的代码如下:
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
我尝试创建一个新的列表视图以获取默认选项,但是它仍然相同。
答案 0 :(得分:1)
因此,根据我在link中共享的同一former question of yours,此方法应该有效:
'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....