如果相邻单元格大于所选单元格,我需要删除一行。本质上,如果 J 中的一个单元格大于 K 中的相邻单元格,我希望删除该行。因此,如果 J100 > K100,则应删除第 100 行中的所有数据。我目前能够使用固定值进行处理,因此如果 J100 > 0 但不能使用不断变化的值。对于固定值,我有:
Sub Delete_Row_Based_On_Bigger_Smaller_Value()
Dim ws As Worksheet
' Dont this bit, unless editted on a differently named sheet in which case replace sheet name with relevant sheet
Set ws = ThisWorkbook.Worksheets("Data Set")
ws.Activate
' Apply Filter. Edit the "ws.Range" with the letter you want to filter. Edit Criterial with what you want to delete. Dont touch the AutoFilter
ws.Range("Q2:Q143691").AutoFilter Field:=1, Criteria1:="<400000"
' Delete Rows. Edit the "ws.Range" to be consistant with the above. Dont touch anything else
Application.DisplayAlerts = False
ws.Range("Q2:Q143691").SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
' Clearing Filter. Dont touch this
On Error Resume Next
ws.ShowAllData
On Error GoTo 0
End Sub
任何帮助将不胜感激,谢谢!

