如何设置此范围边框?

时间:2016-08-09 03:12:50

标签: excel vba excel-vba

我想设置这样的边框。

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

如何在我的范围的内部细胞之间获得一个薄的中间边界?

1 个答案:

答案 0 :(得分: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