Hello,
I'm trying to delete some Table Rows based on a cells Interior Color as applied by a Conditional Formatting rule.
The CF is applied to two columns (B:C) in my Test Workbook.
I came across two threads that are trying to do something similar:
The first one is closer to what I'm trying to do, while the 2nd thread is far too complex for me to decipher.
What I'm working with:
As above, I get a compile error:
Sample Data:
Here's what I was hoping would happen:
The OP from that above thread indicated everything worked as is... but that doesn't seem to be the case unless I didn't make the appropriate changes.
I'm using RGB values, while he was using just a value of '3'.
Thank you,
I'm trying to delete some Table Rows based on a cells Interior Color as applied by a Conditional Formatting rule.
The CF is applied to two columns (B:C) in my Test Workbook.
I came across two threads that are trying to do something similar:
Macro to delete rows based on cell color
I created the following macro to delete all rows that have a cell background color of Yellow in Column D Sub deleterow() Dim myRange as Range Dim cell As Range Application.Calculation = xlCalculationManual Set myRange = Worksheets(1).Range("D2:D1200") For Each cell In...
www.mrexcel.com
Conditional Formatting issues with VBA insert/delete row
Hi, I’m hoping someone can help…I’ve read through quite a lot of threads and see that what I’m struggling with seems like a common thing…but I still can’t figure it out….I think my mind is zonked as I’m not a regular Excel user. Quick outline: I'm struggling to add/keep conditional formatting...
www.mrexcel.com
The first one is closer to what I'm trying to do, while the 2nd thread is far too complex for me to decipher.
What I'm working with:
VBA Code:
Sub DeleteTableRowsByColor()
' Delete Table Rows based on Cell Interior Color (B:C)
Dim myRange As Range
Dim i As Range
Application.Calculation = xlCalculationManual
Set myRange = Worksheets(1).Range("B2:C8")
For i = myRange.Rows.Count To 1 Step -1
If myRange(i).Interior.ColorIndex = RGB(255, 199, 206) Then
myRange(i).EntireRow.Delete
End If
Next i
Application.Calculation = xlCalculationAutomatic
End Sub
As above, I get a compile error:
Sample Data:
VBA Testing.xlsm | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | ID | Author | Series | ||
2 | 100 | Dr. Seuss | Berenstain Bears | ||
3 | 101 | Larrison, Joanne | |||
4 | 102 | Lucado, Max | |||
5 | 103 | Mayer, Mercer | Corduroy | ||
6 | 104 | Rey, Margret | Zonderkidz | ||
7 | 105 | Sendak, Maurice | Dr. Seuss | ||
8 | 106 | Willems, Mo | |||
Delete Table Rows |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
A2:C8,E2:G3 | Expression | =SUM(COUNTIF(A2,"*"&lstPreferred&"*")) | text | NO |
Here's what I was hoping would happen:
The OP from that above thread indicated everything worked as is... but that doesn't seem to be the case unless I didn't make the appropriate changes.
I'm using RGB values, while he was using just a value of '3'.
Thank you,