Thread: Border VBA
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pete pete is offline
external usenet poster
 
Posts: 88
Default Border VBA

When I recorded this part of my macro I noticed that all
the option for the Left,Right,Top and Bottom edges of the
cells are the same. Is there a way to combine all these
into one selection to eliminate the repeatitive code.

Range("DCard1:Dcard1a").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle =
xlNone

Thanks
Pete