我有一个很长的报告,其中有几列的0值持续了数百行。0值通常从第50行附近开始,但有时仅从第200行开始。我有一个代码,它做了它所需要的,但需要大量的PC资源,并可能需要几个小时来处理,从而保持整个过程。
Application.Goto Workbooks("doc_flow_report.xlsx").Sheets("Sheet1").Range("a2")
Application.ScreenUpdating = False
Dim N As Long, i As Long
N = Cells(Rows.Count, "B").End(xlUp).Row
For i = N To 2 Step -1
If Cells(i, "B").Value = Cells(i, "G").Value Then
Cells(i, "B").EntireRow.Delete
End If
Next i
End Sub
我想使用另一种方法,可能会更快地为Excel消化。处理步骤如下:
1.定义一个范围,从B列的第一行(值为0)开始,一直到P列的最后一行(值为0)
1.清除范围的内容。
谢谢任何提示
2条答案
按热度按时间yacmzcpb1#
使用
Range.Find
两次:请注意,第一个
Find
开始搜索 after cellB1
。根据您的描述,这应该不是问题:“0值通常从第50行左右开始。”332nm8kg2#
清除范围
Application.Match
来确定单个列中匹配(找到)值的行索引。