condense code for gridelines

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

Guest

Is there a way to shorten this code a bit. I recorded this macro and just
feel there is a way to condense it, I'm just not sure how. All I'm trying to
do is add grid lines to my sheet. This macro formats about 2 dozen pages so
the less code the better. Thanks

Columns("A:H").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
 
SITCFanTN said:
Is there a way to shorten this code a bit. I recorded this macro and just
feel there is a way to condense it, I'm just not sure how. All I'm trying to
do is add grid lines to my sheet. This macro formats about 2 dozen pages so
the less code the better. Thanks


Hi SITCFanTN

Try:

Columns("A:H").Borders.LineStyle = xlContinuous


Regards

Steve
 
Back
Top