|
- Sub DeleteRowsWithZeroBoxes()
- Dim ws As Worksheet
- Set ws = ThisWorkbook.Sheets("Sheet1") ' 修改为你的工作表名称
- Dim lastRow As Long
- lastRow = ws.Cells(ws.Rows.count, "B").End(xlUp).Row
-
- Dim i As Long
- Dim batchNumber As String
- Dim searchString As String
- Dim foundCell As Range
-
- ' 从最后一行开始向上遍历,以避免在删除行时影响未检查的行
- For i = 1 To lastRow Step 1
- batchNumber = ws.Cells(i, "B").Value
- searchString = batchNumber & "还剩0盒"
-
- ' 在D列中查找拼接后的字符串
- Set foundCell = ws.Columns("E").Find(What:=searchString, LookIn:=xlValues, LookAt:=xlWhole)
-
- ' 如果找到了,删除整行
- If Not foundCell Is Nothing Then
- Range("A" & i & ":E" & i).ClearContents
- End If
- Next i
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|