2015-02-23 55 views
0

我想知道如何將粗厚的右邊框應用於Excel上的所有選定單元格,最好使用快捷方式。我嘗試錄製一個宏,然後應用一個厚邊框,並刪除頂部,底部和左側的單元格,但這隻意味着頂部單元格具有正確的邊框,剩下的選區具有左側和右側邊框。如何將粗邊框應用於單元格的一側

我只在excel上發現了宏,所以如果有我需要輸入的代碼,如果你不介意告訴我在輸入代碼之前和之後要執行的代碼,那將會很棒。

回答

0

這應該工作:

Sub ThickLeftBorders() 
'Clear existing borders 
Selection.Borders.LineStyle = xlNone 
'Apply left border 
With Selection.Borders(xlEdgeLeft) 
    .LineStyle = xlContinuous 
    .Weight = xlThick 
End With 
'Apply inside border (Left on all other columns in range) 
With Selection.Borders(xlInsideVertical) 
    .LineStyle = xlContinuous 
    .Weight = xlThick 
End With 
End Sub 
2

像這樣的東西應該工作...

Dim MyRange as range 
MyRange = activesheet.range("C1:C14") 
MyRange.Borders(xlEdgeRight).LineStyle = xlContinuous 
MyRange.Borders(xlEdgeRight).Weight = xlThick 
MyRange.Borders(xlInsideVertical).LineStyle = xlContinuous 
MyRange.Borders(xlInsideVertical).Weight = xlThick 

選擇來代替MyRange Range對象

Selection.Borders(xlEdgeRight).LineStyle = xlContinuous 
Selection.Borders(xlEdgeRight).Weight = xlThick 
Selection.Borders(xlInsideVertical).LineStyle = xlContinuous 
Selection.Borders(xlInsideVertical).Weight = xlThick 

其他線路的使用體重常數...

'other weight constants... 
    'xlHairline 
    'xlMedium 
    'xlThick 
    'xlThin 
相關問題