• 单元格设边框


    对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  

  • 相关阅读:
    录制游戏视频——fraps
    ssh 带端口登录
    You have new mail in /var/spool/mail/root 烦不烦你?
    php生成xml的四种方法(转)
    liunx命令之whereis、which、find的区别和联系
    wancms从apache迁移至nginx
    面试题
    NP
    Careercup | Chapter 7
    OS | 哲学家问题
  • 原文地址:https://www.cnblogs.com/itecho/p/1340088.html
Copyright © 2020-2023  润新知