Hi everyone,
I'm new to VBA programming, but with a lot of searching and studying code examples I have managed to make 3 working macros today. However I am stuck on the last one that I need to create. The aim is to have a macro that deletes and re-establishes our two conditional formatting rules on our sheet. The ranges overlap, and this seems to cause it the macro to stop working. If I run a version of the macro with either 1 rule at a time it works fine. If I run the whole thing with both rules, it gives a runtime error 438 and debug highlights the line ending xlDuplicate.
Sub ConditionalFormatting()
'
' ConditionalFormatting Macro
' Repair Conditional formatting
'
' Keyboard Shortcut: Ctrl+t
'Reinstate correct condtional formatting
With Sheets("TnT")
With .Range("B178:L10177")
.FormatConditions.Delete
.FormatConditions.Add xlExpression, Formula1:="=$K178:$K10177<=$F$2+7"
.FormatConditions(1).Interior.Color = RGB(230, 184, 183)
End With
With .Range("B178:B10177")
.FormatConditions.AddUniqueValues
.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).DupeUnique = xlDuplicate
.FormatConditions(1).Interior.ColorIndex = 46
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions(1).StopIfTrue = False
End With
End With
End Sub
What changes can I implement to get this to work?
Also, I was hoping someone could please explain to me how this line of code works?
.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Thank you in advance!!
Bookmarks