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
而且範圍只能用.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
留言
張貼留言