Excel Borders設定框線

原來設定框線要做四次,上下左右

而且範圍只能用.Range(.Cells(2, 8), .Cells(2, 17))不能使用.cells(.Cells(2, 8), .Cells(2, 17))

雖然,使用cells會比較快一些,但是在無法使用之下,也是沒辦法的           

Set LinStyle = .Range(.Cells(2, 8), .Cells(2, 17))

                With LinStyle

                    .Borders(xlEdgeLeft).Weight = xlMedium

                    .Borders(xlEdgeTop).Weight = xlMedium

                    .Borders(xlEdgeBottom).Weight = xlMedium

                    .Borders(xlEdgeRight).Weight = xlMedium             

 End With



技巧 069

 Sub AddBorders()

     Dim rng As Range

     Set rng = Range("B2:F10")

     With rng.Borders    '設定儲存格範圍框線

         .LineStyle = xlContinuous

         .Weight = xlThin

         .ColorIndex = 5

     End With

     rng.BorderAround xlContinuous, xlMedium, 5    '應用外框線

     Set rng = Nothing

 End Sub



 Sub AddBorders_1()

     Dim rng As Range

     Set rng = Range("B2:F10")

     With rng.Borders(xlInsideHorizontal)       '設定儲存格範圍水平方向框線

         .LineStyle = xlDot

         .Weight = xlThin

         .ColorIndex = 5

     End With

     With rng.Borders(xlInsideVertical)         '設定儲存格範圍垂直方向框線

         .LineStyle = xlContinuous

         .Weight = xlThin

         .ColorIndex = 5

     End With

     rng.BorderAround xlContinuous, xlMedium, 5 '設定儲存格範圍外框線

     Set rng = Nothing

 End Sub

留言

這個網誌中的熱門文章

超任 三國志3代,登入武將金手指

歐姆龍 HEM-7600T 評價,購買心得分享(打臉文)

年青人眼鏡評價(負評),辛酸血淚史分享文