+ Reply to Thread
Results 1 to 3 of 3

sum up an unknown number of rows

  1. #1
    Registered User
    Join Date
    03-12-2006
    Posts
    3

    sum up an unknown number of rows

    Hello. I think it's simple problem but as newbee in VBA it's a big one for me.

    First an example how my table could look like:
    (I used simple numbers for the example, nomally these numbers are calculated with several fomulars)

    Set1
    20
    40
    20
    Sum: 80

    Set2
    20
    30
    Sum: 50

    Set3
    30
    Sum: 30


    The sum of every set should be calculated automatically with a formular. Not a big deal but the problem is the following:
    You can add new numbers in every Set with a makro. Therefore I don't know how many rows I have to use to calculate the sum.
    I need a script which sums all the rows between the beginning and the end of every single set. The calculation of the sum should also work, if you delete one row or number.

    Thank you for any help in advance.

    cheers
    Stefan

  2. #2
    Bob Phillips
    Guest

    Re: sum up an unknown number of rows


    n=0
    For i = 1 to Cells(Rows.Count,"A").End(xlUp).Row
    If Cells(i,"A").Value = "" Then
    Cells(i,"A").Value = n
    Else
    If Left(Cells(i,"A").Value,3) <> "SET" Then
    n = n + Cells(i,"A").Value
    End If
    End If
    Next i

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "skoller" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hello. I think it's simple problem but as newbee in VBA it's a big one
    > for me.
    >
    > First an example how my table could look like:
    > (I used simple numbers for the example, nomally these numbers are
    > calculated with several fomulars)
    >
    > SET1
    > 20
    > 40
    > 20
    > SUM: 80
    >
    > SET2
    > 20
    > 30
    > SUM: 50
    >
    > SET3
    > 30
    > SUM: 30
    >
    >
    > The sum of every set should be calculated automatically with a
    > formular. Not a big deal but the problem is the following:
    > You can add new numbers in every Set with a makro. Therefore I don't
    > know how many rows I have to use to calculate the sum.
    > I need a script which sums all the rows between the beginning and the
    > end of every single set. The calculation of the sum should also work,
    > if you delete one row or number.
    >
    > Thank you for any help in advance.
    >
    > cheers
    > Stefan
    >
    >
    > --
    > skoller
    > ------------------------------------------------------------------------
    > skoller's Profile:

    http://www.excelforum.com/member.php...o&userid=32388
    > View this thread: http://www.excelforum.com/showthread...hreadid=521522
    >




  3. #3
    Registered User
    Join Date
    03-12-2006
    Posts
    3
    Thank you for the quick reply.

+ 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