"Linestyle" in Macro

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?
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top