简体   繁体   English

VBA条件格式+删除单元格

[英]VBA Conditional Formatting + Delete cells

Is there a method to delete a whole row based upon a cell in it using VBA? 有没有一种方法可以使用VBA基于其中的单元格删除整行?

Trying to complete the following task: 尝试完成以下任务:

  1. Select whole row based upon a cell in it in my case cell value <3 在我的案例单元格值<3中,根据其中的单元格选择整行
  2. Delete entire row 删除整行

I used CF to achieve the first part, but when trying to delete the highlighted cells (color from CF), the color cannot be found by the Find Function. 我使用CF来实现第一部分,但是当尝试删除突出显示的单元格(CF中的颜色)时,查找功能无法找到颜色。

Can anyone redirect me to a specific post please been looking for hours. 任何人都可以将我重定向到特定的帖子,请找几个小时。
Danke 丹科

How about something like this: 这样的事情怎么样:

Sub Delete3()

Dim F As Integer
Dim Y As Integer
Dim RngCount As Range


Set RngCount = ActiveSheet.Range("COLUMN:COLUMN")
Y = Application.WorksheetFunction.CountA(RngCount)

For F = Y To 1 Step -1

If ActiveSheet.Range("COLUMN" & F).Value < 3 Then
ActiveSheet.Rows(F).EntireRow.Delete
End If

Next F

End Sub

You just need to replace the word COLUMN with the letter of the column where the values are, eg "C:C" and "C". 您只需要将值COLUMN替换为值所在列的字母,例如“C:C”和“C”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM