Sub Chadsrebate()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If sheet2.Cells(Rows.Count, 2).Value <>"A","B","C","D" then
entirerow.delete
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
-2
A
回答
2
的方式,你如何能做到这一个:如果你想删除它们包含名称中的所有行
:
Option Compare Text
Sub Chadsrebate()
Dim i&, z&
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
With Sheets("Sheet2")
i = .Cells(Rows.Count, "B").End(xlUp).Row
For z = i To 2 Step -1
If .Cells(z, "B").Value2 Like "*A*" _
Or .Cells(z, "B").Value2 Like "*F*" _
Or .Cells(z, "B").Value2 Like "*Z*" _
Or .Cells(z, "B").Value2 Like "*Q*" Then
.Rows(z).Delete
End If
Next z
z = .Cells(Rows.Count, "B").End(xlUp).Row
End With
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
MsgBox i - z & " Rows has been deleted!"
End Sub
,如果你想要删除所有不包含名称的行:
Option Compare Text
Sub Chadsrebate()
Dim i&, z&
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
With Sheets("Sheet2")
i = .Cells(Rows.Count, "B").End(xlUp).Row
For z = i To 2 Step -1
If Not (.Cells(z, "B").Value2 Like "*A*" _
Or .Cells(z, "B").Value2 Like "*F*" _
Or .Cells(z, "B").Value2 Like "*Z*" _
Or .Cells(z, "B").Value2 Like "*Q*") Then
.Rows(z).Delete
End If
Next z
z = .Cells(Rows.Count, "B").End(xlUp).Row
End With
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
MsgBox i - z & " Rows has been deleted!"
End Sub
相关问题
- 1. 删除基于名称
- 2. 删除基于名称
- 3. 删除基于名称的文件夹
- 4. 删除基于名称的jQuery验证
- 5. 基于名称删除文件
- 6. Applescript删除文件,该名称不包含“_s”
- 7. 当名称不包含某些词时删除文件
- 8. 包含名称
- 9. 删除名称包含'_nd'的列,重命名其中名称包含'_er'的列?
- 10. 删除包含零的行
- 11. vba编程 - 删除整行,不包含
- 12. 合并基于行名称
- 13. R:基于与行名称
- 14. 删除包含
- 15. 删除不包含在PHP
- 16. 删除不包含与jQuery
- 17. 删除不包含在
- 18. 基于包含函数名称的字符串调用函数
- 19. 更改基于包含文件的XSLT的节点名称
- 20. 基于列值删除行
- 21. 删除基于另一行
- 22. 基于名称
- 23. 基于名称
- 24. 基于名称
- 25. 基于条件不工作删除行
- 26. 删除链接,如果链接名称包含字符串
- 27. 如何删除名称中包含“:”的mongodb db?
- 28. 删除多个包含子字符串名称的文件
- 29. 删除所有包含在blob存储中的名称
- 30. 如何删除名称中包含无效字符的分支?
那么......这是什么问题?你期望看到什么?你真正看到了什么? – grimstoner
看看你最后的[问题](http://stackoverflow.com/questions/33656858/scroll-through-column-from-top-to-bottom-and-replace-0s-with-value-from-cell- ab),你需要用循环做几乎完全相同的事情,唯一的区别是你正在循环的列和if语句。使用该信息并查看IF..AND语句然后返回。 –
因此,我有一个包含全部客户名称的数据。我需要删除所有行,但包含所述A,B,C,D等的行。在那之后我得到一个错误。 – ichoi