"Linestyle" in Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Macro that identifies some sets of Rows, and based on the result,
highlights them with a background color. Because some of the sets are
contiguous, I want to separate them with a thick line. This code works after
a fashion:

Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(("A" & NewStartRow - varOffset), ("S" &
NewStartRow - 1)).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone

However if there are two contiguous sets, the Line under the first set gets
overwritten by the "Selection.Borders(xlEdgeTop).LineStyle = xlNone"
expression.
Do I need the xnone lines at all?
 
You can delete any of the border commands you don't want to actually change.
It might be better to comment them out first and test it to make sure it does
what you want.
 
Back
Top