0
我有一个代码,它可以比较同一工作表中的两个列表,并从两个列表中的一个列表中删除整行,但它现在运行非常缓慢(随着数据的增长)和我正在努力加快这一进程。试图加快EXCEL VBA中的列表比较
我不是在做这个以任何很大程度上随后,我找一些援助,
谢谢!
代码:
Sub Clean_Up_Lists()
'run comparisons... clean up lists'
'turn of screen updating to speed up macro'
Application.ScreenUpdating = False
Dim iListCount As Long
Dim x As Range
Dim iCtr As Long
'get count of records to search through(list that will be deleted)'
iListCount = Sheets("Allocations").Cells(Rows.Count, "B").End(xlUp).Row
For Each x In Sheets("Allocations").Range("N200:N400" & Sheets("Allocations").Cells(Rows.Count, "B").End(xlUp).Row)
'loop through all records in the second list'
For iCtr = iListCount To 1 Step -1
If x.Value = Sheets("Allocations").Cells(iCtr, 2).Value Then
Sheets("Allocations").Cells(iCtr, 2).EntireRow.ClearContents
'if match exists --> clear contents from allocations list'
End If
Next iCtr
Next
Application.ScreenUpdating = True
End Sub
您预计这部分'的东西。 “N200:N400” 和表格( “分配”)细胞(Rows.Count“ B“)。结束(xlUp).Row'应该做什么? –
这段代码实现了大约12个月,我的回忆是它定义了比较删除值的列表。 (基本上遍历主列表) 现在重新阅读它,我不知道这样做是否有冗余? – Guterres
如果最后使用的拖拽,比如说500,这一行'“N200:N400”&Sheets(“Allocations”)。Cells(Rows.Count,“B”).End(xlUp).Row'给你'“N200 :N400500" '。不确定它是你需要的 –