我基本上想知道将工作表中的项目与列表框进行比较的最佳方法是什么,基本上,列表框中的项目需要在工作表上找到,如果找不到,则需要转到工作表的底部下一个空闲行,
这应该不会太难,但我尝试过使用 if 语句,但发现它必须搜索工作表上的所有行以及列表框中的所有行,这使得它有时滞后、耗时且无响应,
我正在考虑使用 .find 方法,但不想浪费我的时间,
代码更新:
`
For i = 0 To Me.ListBox1.ListCount - 1
field1 = Me.ListBox1.List(i)
field2 = Me.ListBox1.List(i, 1)
field3 = Me.ListBox1.List(i, 2)
field2ammend = Right(field2, Len(field2) - 7)
For Each rCell In rRng.Cells
If rCell.Value = field1 Then
comp = field3
name = field2ammend
Sheets("Hair").Range("E" & rCell.Row) = comp
Sheets("Hair").Range("F" & rCell.Row) = name
Range("A" & rCell.Row & ":H" & rCell.Row).Interior.ColorIndex = 24
countgood = countgood + 1
Else
ListBox2.AddItem (field2)
'bal = bal + 1
'Sheets("Hair").Range("B" & lastrows) = field1
'Sheets("Hair").Range("E" & lastrows) = comp
'Sheets("Hair").Range("F" & lastrows) = name
'Range("A" & lastrows & ":H" & lastrows).Interior.ColorIndex = 24
'lastrows = lastrows + 1
'countbad = countbad + 1
End If
下一个 rCell 下一个 i
`
有什么建议么,
谢谢,