我想知道如何在Excel上为所有选定的单元格应用更粗的右边框,最好使用快捷方式。我尝试录制一个宏,然后应用一个粗边框并擦除顶部,底部和左边的单元格,但这只是意味着只有顶部单元格有正确的边框,其余的选择有左右边框。
我只是在excel上发现了宏,所以如果我需要输入代码,如果你不介意告诉我在输入代码之前和之后要做什么,以便它能够工作,那会很棒。
答案 0 :(得分:4)
这样的事情应该有用......
Dim MyRange as range
MyRange = activesheet.range("C1:C14")
MyRange.Borders(xlEdgeRight).LineStyle = xlContinuous
MyRange.Borders(xlEdgeRight).Weight = xlThick
MyRange.Borders(xlInsideVertical).LineStyle = xlContinuous
MyRange.Borders(xlInsideVertical).Weight = xlThick
可以使用选择代替MyRange Range对象
Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).Weight = xlThick
Selection.Borders(xlInsideVertical).LineStyle = xlContinuous
Selection.Borders(xlInsideVertical).Weight = xlThick
其他线宽常数......
'other weight constants...
'xlHairline
'xlMedium
'xlThick
'xlThin
答案 1 :(得分:0)
这应该有效:
Sub ThickLeftBorders()
'Clear existing borders
Selection.Borders.LineStyle = xlNone
'Apply left border
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
End With
'Apply inside border (Left on all other columns in range)
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThick
End With
End Sub