我从宏记录器使用此代码并添加for循环。如何从宏记录器改进代码?
如果可能的话,如何更好地执行此代码?
我想用2003年和2010年
Range(Cells(2, 2).Address, Cells(5, 5).Address).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Color = -16777216
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Color = -16777216
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Color = -16777216
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Color = -16777216
.Weight = xlThick
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
代码你怎么想使代码更优秀?代码有什么问题? – stormCloud 2013-04-06 11:53:26
http://stackoverflow.com/questions/10714251/excel-macro-avoiding-using-select/10718179#10718179 – 2013-04-06 12:25:34
为了改善它,我会说永远不要使用选择时使用范围 – 2013-04-06 12:39:35