+ Reply to Thread
Results 1 to 7 of 7

Summing different # of rows

  1. #1
    new2macros
    Guest

    Summing different # of rows

    How do I write a macro that will enter the sum in the last row, regardless
    of how many rows I have listed.

    For example:
    Will calculate ttl here: but also here:
    Item Qty Item
    Qty
    A 1 F
    7
    B 2 G
    8
    C 3 H
    9
    Total: 6 I
    10

    J 11

    Total: 45

    Thank you very much for your help and expertise!

  2. #2
    new2macros
    Guest

    RE: Summing different # of rows

    Let me try rewriting that quest so it is more legible.
    I would like to enter the sum of all previous rows when the number of rows
    changes from worksheet to worksheet.
    For example:
    Worksheet1
    Item Qty
    A 1
    B 2
    C 3
    Ttl: 6

    In Worksheet2
    Item Qty
    A 1
    B 2
    C 3
    D 4
    E 5
    Ttl: 15

    Thank you for your help



  3. #3
    Chip
    Guest

    Re: Summing different # of rows

    Length = ActiveSheet.UsedRange.Rows.Count
    sumtotal = WorksheetFunction.Sum(Range(Cells(1, 1), Cells(Length, 1)))
    Cells(Length + 1, 1).Value = sumtotal


    And in my macro there, change it so that wherever it says Cells(#,#)
    the second number should be the number of the column that the data to
    be summed is in.


  4. #4
    Chip
    Guest

    Re: Summing different # of rows

    Length = ActiveSheet.UsedRange.Rows.Count
    sumtotal = WorksheetFunction.Sum(Range(Cells(1, 1), Cells(Length, 1)))
    Cells(Length + 1, 1).Value = sumtotal


    And in my macro there, change it so that wherever it says Cells(#,#)
    the second number should be the number of the column that the data to
    be summed is in.


  5. #5
    Bob Phillips
    Guest

    Re: Summing different # of rows

    Try this

    =SUM(OFFSET(B2,,,COUNTA(A:A)-2))

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "new2macros" <[email protected]> wrote in message
    news:[email protected]...
    > Let me try rewriting that quest so it is more legible.
    > I would like to enter the sum of all previous rows when the number of rows
    > changes from worksheet to worksheet.
    > For example:
    > Worksheet1
    > Item Qty
    > A 1
    > B 2
    > C 3
    > Ttl: 6
    >
    > In Worksheet2
    > Item Qty
    > A 1
    > B 2
    > C 3
    > D 4
    > E 5
    > Ttl: 15
    >
    > Thank you for your help
    >
    >




  6. #6
    Bob Phillips
    Guest

    Re: Summing different # of rows

    something like

    =AVERAGE(IF(B2:B10>2,B2:B10))

    which is an array formula, so commit with Ctrl-Shift-Enter

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "new2macros" <[email protected]> wrote in message
    news:[email protected]...
    > How do I write a macro that will enter the sum in the last row,

    regardless
    > of how many rows I have listed.
    >
    > For example:
    > Will calculate ttl here: but also here:
    > Item Qty Item
    > Qty
    > A 1 F
    > 7
    > B 2

    G
    > 8
    > C 3

    H
    > 9
    > Total: 6 I
    > 10
    >
    > J 11
    >
    > Total: 45
    >
    > Thank you very much for your help and expertise!




  7. #7
    Bob Phillips
    Guest

    Re: Summing different # of rows

    sorry, response to another question.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Bob Phillips" <[email protected]> wrote in message
    news:OZSYqC%[email protected]...
    > something like
    >
    > =AVERAGE(IF(B2:B10>2,B2:B10))
    >
    > which is an array formula, so commit with Ctrl-Shift-Enter
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "new2macros" <[email protected]> wrote in message
    > news:[email protected]...
    > > How do I write a macro that will enter the sum in the last row,

    > regardless
    > > of how many rows I have listed.
    > >
    > > For example:
    > > Will calculate ttl here: but also here:
    > > Item Qty Item
    > > Qty
    > > A 1

    F
    > > 7
    > > B 2

    > G
    > > 8
    > > C 3

    > H
    > > 9
    > > Total: 6

    I
    > > 10
    > >
    > > J 11
    > >
    > > Total: 45
    > >
    > > Thank you very much for your help and expertise!

    >
    >




+ 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