【问题标题】:How do I apply a thick border to one side of cell如何在单元格的一侧应用粗边框
【发布时间】:2015-02-25 01:28:00
【问题描述】:

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

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

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    这样的东西应该可以工作......

    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 
    

    Selection 可以用来代替 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 
    

    【讨论】:

      【解决方案2】:

      这应该可行:

      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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-08-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-16
        相关资源
        最近更新 更多