![](/img/trans.png)
[英]How to locate a cell value that ends in “net” and delete row in Excel VBA
[英]Excel 2007 VBA: delete row if cell value is between 600 and 699
我一直在努力解决这个问题。 我正在尝试编写VBA代码来完成此多工作表宏,在此先感谢您的时间和知识。 我衷心感谢。
我大约有10列,4,000行。 目标是在“ E”列中搜索600到699之间的值,并删除所有E列在600到699之间的值的行。
现在,我正在使用此行删除包含“ 602”的行:
Dim FoundCell As Range
Set FoundCell = Worksheets("StoreEmployeeImport").Range("E:E").Find(what:=602)
Do Until FoundCell Is Nothing
FoundCell.EntireRow.Delete
Set FoundCell = Worksheets("StoreEmployeeImport").Range("E:E").FindNext
Loop
是否可以对600到650之间的所有值执行此操作? “快速而肮脏的方式”是为600至650 BUT之间的所有五十个可能值编写此循环,我知道这是一种更好的方式,可能简单得多。
谢谢!
这就是我的处理方式
'Get the last row, 65000th row and column E
finalRow=cells(65000,5).end(xlup).row
'Loop through data backwards
for i = finalRow to 1 step -1
'Do your check
if cells(i,5) > 600 and cells(i,5) < 650 then
'Delete the row if criteria met
cells(i,1).entirerow.delete
end if
next i
尝试这个:
Sub qwerty()
Dim N As Long, i As Long
N = Cells(Rows.Count, "E").End(xlUp).Row
Application.ScreenUpdating = False
For i = N To 1 Step -1
v = Cells(i, "E").Value
If v > 599 And v < 700 Then
Cells(i, "E").EntireRow.Delete
End If
Next i
Application.ScreenUpdating = True
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.