+ Reply to Thread
Results 1 to 7 of 7

Auto Sum

  1. #1
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Auto Sum

    I would like to add an auto sum in my macro. This is my issue:

    when my macro finishes, on column B, I would like to have to total up b2 to whatever is the last cell that contains the value in column B. If the last value ends in B10, I would like B12 to have the total. If the last value ends in B13, I would like B15 to have the total. Please help. Thank you.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Auto Sum

    Hi,

    Is this what you want?

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Auto Sum

    Perhaps:

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 10-15-2009 at 08:43 AM. Reason: typo - cells not range

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Auto Sum

    Range(Rows.Count,"B").End(xlUp).Offset(2).Formula = "=SUM(R2C:R[-1]C)"
    Well, if you want to be concise and efficient about it.....

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Auto Sum

    ha - not really - first there's a typo - should be Cells not Range.

    It was more to show working bottom-up as generally it's a little safer, here for example if there are no values in B you will get

    B3: =SUM(B$2:B2)

    for one value (B2) you'd get

    B4: =SUM(B$2:B3)

    using down method you'd get an error in both cases.

  6. #6
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Re: Auto Sum

    Hi everybody

    SWEEP - It worked perfectly. Thank you very much. Also thank you for others effort assistance. I tried them and worked the same way.

    I really appreciated all your efforts. Thank you.

  7. #7
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Auto Sum

    Yup, my mistake (as usual) assuming that there wouldn't be blanks. Another day, another lesson learned!

+ 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