SonicBoomGolf
Active Member
- Joined
- Aug 7, 2004
- Messages
- 325
Simple question for the pros here. Is there a way to shorted the code needed to put borders around cells? Attached is some code I recorded with the macro recorder which puts borders around cells.
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
I am trying to use something similar to the following to shorten the code.
Dim formatRng As Range
Set formatRng = Application.Union(xlEdgeLeft, xlEdgeRight, xlEdgeTop, xlEdgeBottom)
With formatRng.Borders
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
Any ideas??
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
I am trying to use something similar to the following to shorten the code.
Dim formatRng As Range
Set formatRng = Application.Union(xlEdgeLeft, xlEdgeRight, xlEdgeTop, xlEdgeBottom)
With formatRng.Borders
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
Any ideas??