putting count of the number of rows at the bottom

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following lines in a macro that puts the sums of number in column
J at the bottom of all the rows. I want to put the count of rows on the same
row as the sums for column J, but in column D. How do I do that?

lastrow = Cells(Rows.Count, "J").End(xlUp).Row
Cells(lastrow + 1, "J") = Application.Sum(Range(Cells(2, "J"),
Cells(lastrow, "J")))
 
Hi lpdarspe,

I thought you wanted the value on the last row.

If you want it on the next row (which now becomes the last row), try:
..Cells(lastrow + 1, 4).Value = lastrow
or, if you want to count the new last row:
..Cells(lastrow + 1, 4).Value = lastrow

Cheers
 
macropod,

That got it!

Thanks!

macropod said:
Hi lpdarspe,

I thought you wanted the value on the last row.

If you want it on the next row (which now becomes the last row), try:
..Cells(lastrow + 1, 4).Value = lastrow
or, if you want to count the new last row:
..Cells(lastrow + 1, 4).Value = lastrow

Cheers
 
Back
Top