+ Reply to Thread
Results 1 to 4 of 4

Insert a sum function after first blank row

  1. #1
    Registered User
    Join Date
    05-24-2013
    Location
    London, England (it's a lie!)
    MS-Off Ver
    Excel 2010
    Posts
    25

    Insert a sum function after first blank row

    Hi all,
    I have a lot of worksheets with identical set-up, although varying rows of data. I have a cost in one column, and a count in another. For each column with a count, I want to sum the total cost. That is, for columns D, E, F, I want to multiply the count of each item to it's cost, then get the total. For example, I have this currently:
    Please Login or Register  to view this content.
    where $C will have my cost. I used this to drag across multiple columns for one sheet.

    However, the amount of rows will be increasing or decreasing and I don't want to have to change the formula each time I add or subtract something. I need a macro that can:
    1. Look at the number of rows and insert a formula after the first blank row
    2. Insert a formula that sums (CostA*QuantityA)+(CostB*QuantityB)+etc for each item in the column
    3. Will dynamically update the formula if there are additions or deletions

    Please let me know if that's not clear or if you need more specifics. I don't mind re-running the macro if/when a row is changed, so # three on the list isn't high priority.
    Last edited by mturnertombow; 12-13-2013 at 05:56 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Insert a sum function after first blank row

    Hi MTurnertombow,

    You can use SUMPRODUCT for this exact application, for example:

    =SUMPRODUCT(C:C*D:D)

    If you have a lot of values, you may want to reduce the range, but make it greater than anything you'd expect, e.g.

    =SUMPRODUCT((C2:C1000)*(D2:D1000))

  3. #3
    Registered User
    Join Date
    05-24-2013
    Location
    London, England (it's a lie!)
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Insert a sum function after first blank row

    I don't know if you could have made that any simpler. I never knew how that works but that is an exceedingly handy tool. Thanks!

  4. #4
    Registered User
    Join Date
    05-24-2013
    Location
    London, England (it's a lie!)
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Insert a sum function after first blank row

    Quote Originally Posted by Paul View Post
    Hi MTurnertombow,

    You can use SUMPRODUCT for this exact application, for example:

    =SUMPRODUCT(C:C*D:D)

    If you have a lot of values, you may want to reduce the range, but make it greater than anything you'd expect, e.g.

    =SUMPRODUCT((C2:C1000)*(D2:D1000))
    Does this not work with Vlookup? My column with Cost is
    Please Login or Register  to view this content.
    and when I use the =SUMPRODUCT(C:C*D:D) it just gives me a 0.


    EDIT: Nevermind. It works.
    Last edited by mturnertombow; 12-12-2013 at 03:56 PM.

+ 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. [SOLVED] Auto insert blank row. (blank copy of row that includes merged cells)
    By rutts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2013, 07:48 PM
  2. Insert blank row, sum and insert page break macro
    By kim5012 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-06-2012, 01:46 AM
  3. How to Insert Blank row and function into blank cell
    By Mrs_T in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2012, 06:14 PM
  4. How to remove blank rows, then insert blank row conditionally, PLUS error proof
    By GTS115 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2009, 11:39 AM
  5. Macro code to test for blank row and insert blank row if false
    By Mattie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2006, 08:25 PM

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