如何在单元格的一侧应用粗边框

0 excel vba

我想知道如何对 Excel 上的所有选定单元格应用较粗的右边框,最好使用快捷方式。我尝试录制一个宏,然后应用粗边框并擦除顶部、底部和左侧的单元格,但这只是意味着只有顶部的单元格具有右边框,其余的选择具有左右边框。

我只是在 excel 上发现了宏,所以如果我需要输入代码,如果您不介意告诉我在输入代码之前和之后要做什么以使其正常工作,那就太好了。

Per*_*rer 5

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

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 
Run Code Online (Sandbox Code Playgroud)

可以使用选择代替 MyRange Range 对象

Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
Selection.Borders(xlEdgeRight).Weight = xlThick 
Selection.Borders(xlInsideVertical).LineStyle = xlContinuous
Selection.Borders(xlInsideVertical).Weight = xlThick 
Run Code Online (Sandbox Code Playgroud)

其他线宽常量...

    'other weight constants...
    'xlHairline 
    'xlMedium 
    'xlThick 
    'xlThin 
Run Code Online (Sandbox Code Playgroud)