Hi. I have a macro that first deletes the present conditional formats on the tab and then creates a new one. When I run the code, I get "Run-time error 9 - Subscript out of range and it highlights the line "Columns("H:H").FormatConditions(Selection.FormatConditions.Count).SetFirstPriority". Why is this happening and how do I fix it? I've tried inserting selection instead of columns("H:H") with no luck. The strange thing is that sometimes (1/5 times) this code runs fine. Any insight would be appreciated. Thanks!

Sub Macro5()
Sheets("Mag-Alum").Select
    With Range("1:1048576")
        .FormatConditions.Delete
    End With
With Mag - Alum
    Columns("H:H").Select
    Columns("H:H").FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=AND(CELL(""type"",$G1)=""v"",CELL(""type"",$H1)=""v"",$H1-$G1<'Conv. Chart'!$J$2)"
    Columns("H:H").FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Columns("H:H").FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    With Columns("H:H").FormatConditions(1).StopIfTrue = False
End With
End With
    Range("A1").Select
End Sub