Chapter-03 格線
第三章 格線
03-01 繪製格線
應用範例
Sub 繪製格線()
MsgBox “在選取的儲存格範圍中繪製格線”
Selection.Borders.LineStyle = xlContinuous
End Sub
03-02 繪製外框線
應用範例1
Sub 繪製上方及底部的格線()
MsgBox “在選取的儲存格範圍中繪製上方及底部的格線”
Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
End Sub
應用範例2
Sub 繪製外框線()
MsgBox “在所選取的儲存格範圍四周繪製外框線”
With Selection
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
End With
End Sub
03-03 變更格線的線條樣式
應用範例
Sub 使用點線來繪製格線()
MsgBox “在選取的儲存格範圍中繪製格線,線條樣式為點線”
Selection.Borders.LineStyle = xlDot
End Sub
03-04 改變格線的粗細
應用範例
Sub 調整格線的粗細度()
MsgBox “將選取的儲存格範圍外框線變粗”
With Selection
.Borders(xlEdgeTop).Weight = xlThick
.Borders(xlEdgeBottom).Weight = xlThick
.Borders(xlEdgeLeft).Weight = xlThick
.Borders(xlEdgeRight).Weight = xlThick
End With
End Sub
03-05 設定格線的顏色
應用範例
Sub 設定格線的顏色()
MsgBox “將選取的儲存格範圍左側的格線顏色設為黃色”
Selection.Borders(xlEdgeLeft).ColorIndex = 6
End Sub
03-06 一次設定多個格線屬性
應用範例
Sub 設定多個格線屬性()
MsgBox “將格線設定為紅色的粗實線”
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
End Sub
03-07 繪製斜線
應用範例
Sub 繪製斜線()
MsgBox “在選取的儲存格內繪製一條由左上到右下的斜線”
Selection.Borders(xlDiagonalDown).LineStyle = xlContinuous
End Sub
03-08 刪除格線
應用範例1
Sub 刪除儲存格的垂直格線()
MsgBox “刪除所選取的儲存格範圍中所有的垂直格線”
Selection.Borders(xlInsideVertical).LineStyle =xlNone
End Sub
應用範例2
Sub 將格線全部刪除()
MsgBox “將所選取的儲存格範圍中所有的格線刪除”
Selection.Borders.LineStyle = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
End Sub
0 Comments:
Post a Comment
<< Home