+ Reply to Thread
Results 1 to 7 of 7

How to program the Autosum feature in Excel

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72

    How to program the Autosum feature in Excel

    Hi there,

    I've recently been using autosum feature quite a bit and was wondering how that could be put into a macro.

    The shortcut is to press Alt and += button.

    I recorded this and tried it but the macro did not have a dynamic range in terms of how many numbers it added. it only copied how many numbers were in the range when I recorded it (eg. 3) and only sums up 3 numbers above now.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to program the Autosum feature in Excel

    The AutoSum is a human shortcut and is meant to work that way. Any attempt to use it in VBA would also require the use of "selecting" and "sendkeys"...neither of which is efficient. Since macros work fastest without utilizing the sheet directly, best to do the work all in VBA.

    There are many ways, all affected by your sheet design. If your column of values stands alone with empty cells all around, this will get you a sum in one line of code:
    Please Login or Register  to view this content.
    The red part could be substituted with a cell reference to indicate a cell you know will always be a part, like the first cell is always M1...
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: How to program the Autosum feature in Excel

    I understood the question a bit different.

    Making an autoSum in VBA
    Please Login or Register  to view this content.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Registered User
    Join Date
    01-14-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: How to program the Autosum feature in Excel

    wow that works great! Thanks very much. And thanks to all who tried to help as well.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How to program the Autosum feature in Excel

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    08-21-2012
    Location
    Saint Louis, MO
    MS-Off Ver
    Excel 2010
    Posts
    3

    Lightbulb Re: How to program the AutoSUBTOTAL feature in Excel

    The code provided by rwgrietveld made me register for this forum, as I was looking for a way to do a autoSUBTOTAL. I know that Alt = will provide the sum function to adjacent cells, but I wanted a similar keyboard shortcut for subtotal. I modified the code to:

    Please Login or Register  to view this content.
    Assigned Ctrl T and now I am good to go.

    Thanks!
    -new member Laura aka flatflo

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to program the Autosum feature in Excel

    Thanks for your added variation, flatflo. And welcome to the forum.

+ 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