我有一个相当简单的代码,我用来遍历excel数据表.基本上,我有超过150,000行数据,我想删除除了其中包含"仪器故障"的那一行以外的每一行,在这种情况下,我想要那行和它上面和下面的那一行(可能包含与失败).这是我的代码:
Sub UnsignedFailure()
Application.ScreenUpdating = False
'Start point
Set r = Range("E1")
'Loop, total rows is a function, executes quickly
For t = 3 To TotalRows
'Check for a failure
k = InStr(1, r.Cells(t, 1).Value, "Instrument Failure")
'Verify that it corresponds to a GC
b = InStr(1, r.Cells(t, 1).Offset(0, -3).Value, "GC")
If k <> 0 And b <> 0 Then
'Skip two rows if it is true
t = t + 2
Else
'Delete the previous row since this row …Run Code Online (Sandbox Code Playgroud)