如何在counta总数之前加下最后一行?

时间:2015-04-23 07:20:13

标签: excel

所以我想了这么多:

    Dim myLastRow As Long

    'Find last row in column A
    myLastRow = Cells(Rows.Count, "A").End(xlUp).Row

'   Insert count after last cell in column A
    Cells(myLastRow + 1, "A").Formula = "=COUNTA(A2:A" & myLastRow & ")"

这会计算一个列并将总数放在底部。但是如何在总数之前的最后一行加下划线?

1 个答案:

答案 0 :(得分:0)

这应该可以解决问题。

Dim myLastRow As Long

'Find last row in column A
myLastRow = Cells(Rows.Count, "A").End(xlUp).Row

'Insert count after last cell in column A
Cells(myLastRow + 1, "A").Formula = "=COUNTA(A2:A" & myLastRow & ")"

With Cells(myLastRow + 1, "A").Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlMedium
End With