2015-02-23 29 views
0

我想知道如何将粗厚的右边框应用于Excel上的所有选定单元格,最好使用快捷方式。我尝试录制一个宏,然后应用一个厚边框,并删除顶部,底部和左侧的单元格,但这只意味着顶部单元格具有正确的边框,剩下的选区具有左侧和右侧边框。如何将粗边框应用于单元格的一侧

我只在excel上发现了宏,所以如果有我需要输入的代码,如果你不介意告诉我在输入代码之前和之后要执行的代码,那将会很棒。

回答

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 
2

像这样的东西应该工作...

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 
相关问题