+ Reply to Thread
Results 1 to 4 of 4

Automatically updates the sum whenever i update quantity

  1. #1
    Registered User
    Join Date
    08-13-2020
    Location
    Pakistan
    MS-Off Ver
    2010
    Posts
    15

    Automatically updates the sum whenever i update quantity

    Hi Guys
    I am doing some excel work using macros.
    Here i am stuck at a point. There is a button name "Add Row" in it. whenever we click this button one row is added in the sheet.
    I want to perform SUM operation at columns for example column "M" starting from M8 to Last added Row. It is working fine as long as i click the Add Row button it add the numbers in that column and show the result in a cell.
    But this formula is defined in a function "Add Row" and always called when this is clicked.
    I want to know where else i can define this formula so that it automatically sum whenever i change quantity of M columns or row is inserted.
    Below is the code. Hope i am able to describe my point

    Please Login or Register  to view this content.
    query_excel_1.png

    Thanks and best regards

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Automatically updates the sum whenever i update quantity

    Not entirely sure why you are doing the sum inside the VBA routine. Why not just drop the SUM formula into the last row? Then the formula would recalculate when you make changes. Every time you add a row, the routine would still overwrite the formula, but that wouldn't strictly be necessary.

    Alternatively you could use a worksheet change event handler to monitor the column and update the total.

    For me though, just use a formula. It's not complicated so there's no overhead.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-13-2020
    Location
    Pakistan
    MS-Off Ver
    2010
    Posts
    15

    Re: Automatically updates the sum whenever i update quantity

    Quote Originally Posted by TMS View Post
    Not entirely sure why you are doing the sum inside the VBA routine. Why not just drop the SUM formula into the last row? Then the formula would recalculate when you make changes. Every time you add a row, the routine would still overwrite the formula, but that wouldn't strictly be necessary.

    Alternatively you could use a worksheet change event handler to monitor the column and update the total.

    For me though, just use a formula. It's not complicated so there's no overhead.
    Dear i want to do this because after automated i will give this file to different members for updating their data and for them it will be difficult for them to update sum everytime they add a row.
    In the example above i am just using one column for simplicity, in real world there are more than one columns as you can see in the image file and also these columns should be increase.

    can you tell me event change handler routine? how it works and how to define this routine?

    Thanks

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Automatically updates the sum whenever i update quantity

    Please post a sample workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Duplicate a Table and Automatically have it Update as Original Table Updates?
    By tomprestriidge in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-16-2018, 12:40 PM
  2. Update quantity in a cell after recording a sale
    By Excel_Ninja123 in forum Excel General
    Replies: 2
    Last Post: 08-10-2016, 10:06 AM
  3. Replies: 4
    Last Post: 01-14-2015, 07:46 AM
  4. Master sheet updates and sub sheet automatically update as well
    By charscribbles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2014, 09:42 PM
  5. [SOLVED] How to Update Names and Quantity on Sheet
    By beartimeusa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-08-2013, 09:57 PM
  6. Update Quantity
    By poojavasti in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-27-2013, 02:44 PM
  7. Creating a master sheet that when I update it, automatically updates others
    By SuzyRussell in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-11-2013, 09:00 AM

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