最后一个单元格上的边框线,即使它是空单元格

最后一个单元格上的边框线,即使它是空单元格

在为每行到最后一个单元格创建边框线时,我遇到了一个问题。如果最后一个单元格有值,它会很好地工作。但是当最后一个单元格为空时,边框线就会停止。

这是我的代码

lastcell = Cells(Rows.Count, 19).End(xlUp).Address
lastrow = Cells(Rows.Count, 19).End(xlUp).Row

Rng = "A11:" & lastcell
Range(Rng).Select
With Selection
    .Borders(xlDiagonalDown).LineStyle = xlNone
    .Borders(xlDiagonalUp).LineStyle = xlNone
    .Borders(xlEdgeLeft).LineStyle = xlContinuous
    .Borders(xlEdgeLeft).Weight = xlThin
    .Borders(xlEdgeTop).LineStyle = xlContinuous
    .Borders(xlEdgeTop).Weight = xlThin
    .Borders(xlEdgeBottom).LineStyle = xlContinuous
    .Borders(xlEdgeBottom).Weight = xlThin
    .Borders(xlEdgeRight).LineStyle = xlContinuous
    .Borders(xlEdgeRight).Weight = xlThin
    .Borders(xlInsideVertical).LineStyle = xlContinuous
    .Borders(xlInsideVertical).Weight = xlThin
    .Borders(xlInsideHorizontal).LineStyle = xlContinuous
    .Borders(xlInsideHorizontal).Weight = xlThin
    .VerticalAlignment = xlCenter
    .WrapText = True
End With

我希望它仍然添加连续的边框线直到最后一个数据值,即使该行的最后一个单元格是空的。

谢谢。

相关内容