[英]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.