+ Reply to Thread
Results 1 to 6 of 6

putting count of the number of rows at the bottom

  1. #1
    lpdarspe
    Guest

    putting count of the number of rows at the bottom

    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")))


  2. #2
    macropod
    Guest

    Re: putting count of the number of rows at the bottom

    Hi lpdarspe,

    Try:
    ..Cells(lastrow, 4).Value = lastrow

    Cheers


    "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    news:B21D5E50-9A7C-4896-8B9E-71DA275161E2@microsoft.com...
    > 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")))
    >




  3. #3
    lpdarspe
    Guest

    Re: putting count of the number of rows at the bottom

    macropod,

    That did not work. It overwrote the data on the last row in column D.

    "macropod" wrote:

    > Hi lpdarspe,
    >
    > Try:
    > ..Cells(lastrow, 4).Value = lastrow
    >
    > Cheers
    >
    >
    > "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    > news:B21D5E50-9A7C-4896-8B9E-71DA275161E2@microsoft.com...
    > > 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")))
    > >

    >
    >
    >


  4. #4
    macropod
    Guest

    Re: putting count of the number of rows at the bottom

    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



    "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    news:C8E37472-A3C5-4AA7-B899-2A10ABC43746@microsoft.com...
    > macropod,
    >
    > That did not work. It overwrote the data on the last row in column D.
    >
    > "macropod" wrote:
    >
    > > Hi lpdarspe,
    > >
    > > Try:
    > > ..Cells(lastrow, 4).Value = lastrow
    > >
    > > Cheers
    > >
    > >
    > > "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    > > news:B21D5E50-9A7C-4896-8B9E-71DA275161E2@microsoft.com...
    > > > 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")))
    > > >

    > >
    > >
    > >




  5. #5
    lpdarspe
    Guest

    Re: putting count of the number of rows at the bottom

    macropod,

    That got it!

    Thanks!

    "macropod" wrote:

    > 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
    >
    >
    >
    > "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    > news:C8E37472-A3C5-4AA7-B899-2A10ABC43746@microsoft.com...
    > > macropod,
    > >
    > > That did not work. It overwrote the data on the last row in column D.
    > >
    > > "macropod" wrote:
    > >
    > > > Hi lpdarspe,
    > > >
    > > > Try:
    > > > ..Cells(lastrow, 4).Value = lastrow
    > > >
    > > > Cheers
    > > >
    > > >
    > > > "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    > > > news:B21D5E50-9A7C-4896-8B9E-71DA275161E2@microsoft.com...
    > > > > 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")))
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  6. #6
    macropod
    Guest

    Re: putting count of the number of rows at the bottom

    Oops - the second one should have been:
    ..Cells(lastrow + 1, 4).Value = lastrow + 1


    "macropod" <invalid@invalid.invalid> wrote in message
    news:4arngbFtq8kvU1@individual.net...
    > 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
    >
    >
    >
    > "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    > news:C8E37472-A3C5-4AA7-B899-2A10ABC43746@microsoft.com...
    > > macropod,
    > >
    > > That did not work. It overwrote the data on the last row in column D.
    > >
    > > "macropod" wrote:
    > >
    > > > Hi lpdarspe,
    > > >
    > > > Try:
    > > > ..Cells(lastrow, 4).Value = lastrow
    > > >
    > > > Cheers
    > > >
    > > >
    > > > "lpdarspe" <lpdarspe@discussions.microsoft.com> wrote in message
    > > > news:B21D5E50-9A7C-4896-8B9E-71DA275161E2@microsoft.com...
    > > > > 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")))
    > > > >
    > > >
    > > >
    > > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1