Consulting

Results 1 to 6 of 6

Thread: Sum Except Last Register

  1. #1
    VBAX Regular pegbol's Avatar
    Joined
    Feb 2005
    Posts
    45
    Location

    Sum Except Last Register

    .
    Hi,

    The formula showed below is located in cell B1 and works OK. But, I would like help me to improve it.

    =SUBTOTAL(9,$A$21:$A$65536)-OFFSET($A$21,(COUNTA($A$21:$A$65536)-1),0)
    What I am pretending to do is subtotal all registers in column A except the last register
    (from A21 ahead).

    Thanks in advance.

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    I don't follow exactly what you're asking...

    If I enter the value 10 in cells A21:A30 (ten rows), I get 90. The sum of 10 rows * 10 less the value of the last cell.

    Is that not what you wanted?
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    VBAX Regular pegbol's Avatar
    Joined
    Feb 2005
    Posts
    45
    Location
    Yes, that is exactly what I want to do.

    Is there any way to improve the formula?.

  4. #4
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    The only change I would make is to maybe go with:

    =SUM($A$21:$A$65536)-OFFSET($A$21,(COUNTA($A$21:$A$65536)-1),0)
    I'm not sure if you had a reason for the subtotal, though, but I don't really see any reason not to use the Sum formula.

    Is there any specific reason you want to improve it? It just appears too long, or you're concerned another user won't understand it?
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    The only reason to use SUBTOTAL is if Autofilter is being enacted here. Otherwise, use SUM.

  6. #6
    VBAX Regular pegbol's Avatar
    Joined
    Feb 2005
    Posts
    45
    Location
    firefytr is right. I will use an autofilter in the column A.

    As you said kpuls, to me the formula seemed too long and I wanted to see if could be improved in another way.

    I apologize if my request was not so clear.

    Appreciate your explanation. Thanks so much for your kind assitance.

    regards,
    Pedro.

Posting Permissions

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