PDA

View Full Version : Need Help Expanding Conditional Formatting Code via VBA



Mulsiphix
08-25-2015, 08:32 PM
Unfortunately, I can't figure out a way to accomplish what I want using the Excel GUI. I'm curious if this can be done using VBA code? The code currently marks Duplicate entries in Column D. I'd like it to extend a border around the conditional formatted cell in Column D and the cell directly to its right in Column E. Is this possible?


What The Code Does
14256


What I Would Like The Code To Do
14257



Sub Excel_HMMap_Conditional_Formatting_P8()
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:A" & lngLastRow).Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriori ty
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Strikethrough = False
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
End With
Selection.FormatConditions(1).Borders(xlLeft).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlRight).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlTop).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlBottom).LineStyle = xlNone
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 15527148
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub