2016-08-09 143 views
1

我想設置這樣的邊框。如何設置此範圍邊界?

what I want to achieve

我的代碼不能像在圖片執行的效果,中間是空的(沒有邊界)與該邊界的厚度。

範圍是A4:B30

With Range(Cells(6, 1), Cells(row, 2))' row is second last row 
    .Borders.LineStyle = xlContinuous 
    .Weight = xlHairline 
End With 

如何獲得我的範圍內部細胞之間的薄中間邊界?

回答

2

對於美觀的改變,總是嘗試錄製宏並閱讀代碼。這是最好的方法。 :)

Sub testBorders() 

With Range(Cells(6, 1), Cells(30, 2)).Borders(xlEdgeRight) 
'/(xlEdgeRight) sets the border only to right most cells 
.LineStyle = xlContinuous 
.Weight = xlMedium '/ as per your pic you are looking for medium weight. 
End With 

End Sub 
+0

還缺三行。頂部,左側,底部(總體上線) – evabb

+2

偉大..現在你知道該怎麼做,以及如何做到這一點。 :)開裂......如果卡住使用宏記錄器。 – cyboashu

+0

我添加3個三個添加頂部,左側,底部 – evabb