zoukankan      html  css  js  c++  java
  • 单元格设边框

    对C3:E6单元格进行操作。宏的代码如下:  
              Range("C3:E6").Select  
              With   Selection  
                      .HorizontalAlignment   =   xlGeneral  
                      .VerticalAlignment   =   xlBottom  
                      .WrapText   =   False  
                      .Orientation   =   0  
                      .AddIndent   =   False  
                      .ShrinkToFit   =   False  
                      .MergeCells   =   True  
              End   With  
              Selection.Borders(xlDiagonalDown).LineStyle   =   xlNone  
              Selection.Borders(xlDiagonalUp).LineStyle   =   xlNone  
              With   Selection.Borders(xlEdgeLeft)  
                      .LineStyle   =   xlContinuous  
                      .Weight   =   xlThin  
                      .ColorIndex   =   xlAutomatic  
              End   With  
              With   Selection.Borders(xlEdgeTop)  
                      .LineStyle   =   xlContinuous  
                      .Weight   =   xlThin  
                      .ColorIndex   =   xlAutomatic  
              End   With  
              With   Selection.Borders(xlEdgeBottom)  
                      .LineStyle   =   xlContinuous  
                      .Weight   =   xlThin  
                      .ColorIndex   =   xlAutomatic  
              End   With  
              With   Selection.Borders(xlEdgeRight)  
                      .LineStyle   =   xlContinuous  
                      .Weight   =   xlThin  
                      .ColorIndex   =   xlAutomatic  
              End   With  
              Selection.Borders(xlInsideVertical).LineStyle   =   xlNone  
              Selection.Borders(xlInsideHorizontal).LineStyle   =   xlNone  
      -----------------------------------------------------------  
      然后就是找出其中需要的代码,并进行修改。  
      假设我定义了一个xlsSheet对象,那么代码可以修改如下:  
              xlsSheet.Range("C3:E6").MergeCells   =   True         '//合并单元格  
              '//下面是设置边框  
              With   xlsSheet.Range("C3:E6").Borders(7)         'xlEdgeLeft  
                      .LineStyle   =   1         'xlContinuous  
                      .Weight   =   2         'xlThin  
                      .ColorIndex   =   -4105         'xlAutomatic  
              End   With  
              With   xlsSheet.Range("C3:E6").Borders(8)         'xlEdgeTop  
                      .LineStyle   =   1  
                      .Weight   =   2  
                      .ColorIndex   =   -4105  
              End   With  
              With   xlsSheet.Range("C3:E6").Borders(9)         'xlEdgeBottom  
                      .LineStyle   =   1  
                      .Weight   =   2  
                      .ColorIndex   =   -4105  
              End   With  
              With   xlsSheet.Range("C3:E6").Borders(10)         'xlEdgeRight  
                      .LineStyle   =   1  
                      .Weight   =   2  
                      .ColorIndex   =   -4105  
              End   With  

  • 相关阅读:
    CSDN修改博客皮肤模板
    2015年第六届蓝桥杯C/C++ A组国赛 —— 第三题:显示二叉树
    2015年第六届蓝桥杯C/C++ A组国赛 —— 第三题:显示二叉树
    2015年第六届蓝桥杯C/C++ A组国赛 —— 第二题:四阶幻方
    2015年第六届蓝桥杯C/C++ A组国赛 —— 第二题:四阶幻方
    2015年第六届蓝桥杯C/C++ B组国赛 —— 第一题:积分之迷
    2015年第六届蓝桥杯C/C++ B组国赛 —— 第一题:积分之迷
    2014年第五届蓝桥杯C/C++ A组国赛 —— 第四题:排列序数
    2014年第五届蓝桥杯C/C++ A组国赛 —— 第四题:排列序数
    2014年第五届蓝桥杯C/C++ A组国赛 —— 第三题:日期差
  • 原文地址:https://www.cnblogs.com/itecho/p/1340088.html
Copyright © 2011-2022 走看看