|
嵌套了一个IF语句,满足条件时记录增加至ListView1,否则,增加至ListView2。结果ListView中出现了空白行,请教如何解决?
代码如下:
Private Sub TextBox1_Change()
ListView1.ListItems.Clear
ListView2.ListItems.Clear
Dim a&
Dim rw As String: rw = Sheet1.Range("B65536").End(xlUp).Row
With Sheet1
For i = 2 To rw
Set ITM1 = ListView1.ListItems.Add()
Set ITM2 = ListView2.ListItems.Add()
If Len(.Cells(i, 5)) <> 0 Then
ITM1.Text = i - 1
ITM1.SubItems(1) = .Cells(i, 2)
ITM1.SubItems(2) = .Cells(i, 3)
ITM1.SubItems(3) = .Cells(i, 4)
ITM1.SubItems(4) = .Cells(i, 5)
ITM1.SubItems(5) = .Cells(i, 6)
Else
ITM2.Text = i - 1
ITM2.SubItems(1) = .Cells(i, 2)
ITM2.SubItems(2) = .Cells(i, 3)
ITM2.SubItems(3) = .Cells(i, 4)
ITM2.SubItems(4) = .Cells(i, 5)
ITM2.SubItems(5) = .Cells(i, 6)
End If
Next i
End With
End Sub
|
|