[英]VBA/EXCEL: Looping Through Cells With Conditional Formatting To Hide Rows Based on ColorIndex
I'm just starting to learn Macros and I'm trying to loop into conditionally formatted cells to look for a specific color which will then be hidden.我刚刚开始学习宏,我正在尝试循环进入条件格式的单元格以查找特定的颜色,然后将其隐藏。 Is there a way I could it in a loop?
有没有办法让它循环? It should function like these:
它应该像这样的 function:
If Sheets("Sheet1").Range("A1").DisplayFormat.Interior.ColorIndex = 2 Then
Range("A1").EntireRow.Hidden = True
End If
If Sheets("Sheet1").Range("A2").DisplayFormat.Interior.ColorIndex = 2 Then
Range("A2").EntireRow.Hidden = True
End If
If Sheets("Sheet1").Range("A3").DisplayFormat.Interior.ColorIndex = 2 Then
Range("A3").EntireRow.Hidden = True
End If
I solved it by doing this:我通过这样做解决了它:
For Each c In Sheets("Sheet1").Range("A1:A56")
If c.DisplayFormat.Interior.ColorIndex = 2 Then
c.EntireRow.Hidden = True
End If
Next c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.