+ Reply to Thread
Results 1 to 3 of 3

Sum at end of data?

  1. #1
    Registered User
    Join Date
    05-02-2005
    Posts
    5

    Sum at end of data?

    I have a spreadsheet with numbers. I really need a code snippet that will go the bottom the data and sum all values in that column.

    My guess is that the code would need to loop through the cells to detect any missing values...once it finds a missing value, sum everything above it.

    Thanks in advance for any help you can provide!

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Here are 2 ways

    the first finds the last used row in column A then places the sum formula in the next row

    The 2nd finds the last used row in any column then places the sum formula in the next row in column A

    Sub SumColumn()
    Dim lRow As Long
    lRow = Cells(Rows.Count, "a").End(xlUp).Row
    Cells(lRow + 1, "a").Value = "=sum(a3:a" & lRow & ")"
    End Sub


    Sub SumColumn()
    Dim lRow As Long
    lRow = Cells.Find(What:="*", SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Row

    Cells(lRow + 1, "a").Value = "=sum(a3:a" & lRow & ")"
    End Sub

  3. #3
    Gary Keramidas
    Guest

    Re: Sum at end of data?

    maybe something like this, assuming column a and data starting in row 1

    Sub add_column()
    Dim lastrow As Long
    lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    Range("A" & lastrow + 1).Formula = "=sum(A1:A" & lastrow & ")"
    End Sub

    --


    Gary


    "gkimmer" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I have a spreadsheet with numbers. I really need a code snippet that
    > will go the bottom the data and sum all values in that column.
    >
    > My guess is that the code would need to loop through the cells to
    > detect any missing values...once it finds a missing value, sum
    > everything above it.
    >
    > Thanks in advance for any help you can provide!
    >
    >
    > --
    > gkimmer
    > ------------------------------------------------------------------------
    > gkimmer's Profile:
    > http://www.excelforum.com/member.php...o&userid=22882
    > View this thread: http://www.excelforum.com/showthread...hreadid=532153
    >




+ 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