Can you guys help me with this. I have tried to modify this but nothing seems to work.
Thanks
I tried to Modify the original code and it works. But for some reason part of my table next to the main one gets deleted.
Here is the code I got
[VBA]Public Sub DeleteData()
Const FORMULA_CHECK As String = "=AND(B7="""",NOT(OR(A7={""Cookies"",""Salt""})))"
Dim rng As Range
Dim lastrow As Long
Dim i As Long
With ActiveSheet
.Columns("J").Insert
.Rows(5).Insert shift:=xlDown
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("J5").Value = "temp"
.Range("J6").Value = "FALSE"
Set rng = .Range("A6").Resize(lastrow, 10)
.Range(rng.FormatConditions(1).AppliesTo.Address).FormatConditions(1).Delet e
.Range("J7").Resize(lastrow - 2).Formula = FORMULA_CHECK
rng.AutoFilter Field:=10, Criteria1:="TRUE"
Set rng = rng.SpecialCells(xlCellTypeVisible)
rng.Delete shift:=xlUp
.Columns("J").Delete
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A6").Resize(lastrow - 1, 9)
rng.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)=1"
rng.FormatConditions(1).Interior.ColorIndex = 15
End With
End Sub
[/VBA]
Also when I run it more than once then I get an error in this line
[VBA].Range(rng.FormatConditions(1).AppliesTo.Address).FormatConditions(1).Delet e[/VBA]