Excelmacrossearch连续3个项目,如果他们在那里删除该行?

我对这个真的很陌生,到目前为止我做了一些macros,但是与此相比很容易。 我认为这需要实际的编程。

我需要在A列中search一个术语。 那么如果它在那里,我需要search栏B的格式。 那么如果那些是真的,我需要在C列中search一个术语。 如果所有3都是真的,我需要删除该行。 有人可以帮忙吗?

到目前为止我有这个代码,这是我在macros观下的唯一的东西。 我以为我很接近,但没有工作。

Dim lngRow As Long Dim lngRows As Long 'Find the last row in Column A lngRows = Range("A" & Rows.Count).End(xlUp).Row For lngRow = lngRows To 2 Step -1 If ThisWorkbook.Sheets(1).Cells(lngRow, "A").Value = "No Longer Employed" And ThisWorkbook.Sheets(1).Cells(lngRow, "E").Style = "Bad" And ThisWorkbook.Sheets(1).Cells(lngRow, "I").Value = "Hire Date" Then ThisWorkbook.Sheets(1).Rows(lngRow).EntireRow.Delete End If Next 

尝试这个…

 Dim indexRow As Long Dim LastRow As Long Dim keyA, keyE, keyI As String Dim colA, colE, colI As Integer keyA = "No Longer Employed" keyE = "Bad" keyI = "Hire Date" colA = 1 ' index of col A colE = 5 ' index of col E colI = 9 ' index of col I indexRow = 2 ' starting Row number from where start the loop 'Find the last row in Column A LastRow = Range("A" & Rows.Count).End(xlUp).Row For indexRow = indexRow To LastRow Step 1 ' this loop increments the indexRow value If ActiveSheet.Cells(indexRow, colA).Value = keyA Then If ActiveSheet.Cells(indexRow, colE).Value = keyE Then If ActiveSheet.Cells(indexRow, colI).Value = keyI Then ActiveSheet.Rows(indexRow).EntireRow.Delete indexRow = indexRow - 1 ' because we have just deleted one row End If End If End If Next