+ Reply to Thread
Results 1 to 6 of 6

Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

  1. #1
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

    Hello Forum and thank you very much in advance for taking a look at my request for VBA code to solve a business problem...

    I'm working on a profitability report by analyzing expenses and revenues of customers by customer owner. I have a data set of hundreds of thousands of rows that contain customers (column A), customer owners (column B), dollars in expenses (column C), and dollars in revenues (column D). There are one or more customers for each customer owner (so I fully expect there to be multiple instances of results in the output for owners with more than one customer). Each customer has its own expense and revenue dollar amount.

    I would like to create a macro button that does the following. For each customer owner, lookup all of their associated customers then:

    1. Total the customer expenses (C) for that customer owner and place that total in column E for that customer owner ID in that row, and
    2. Total the customer revenues (D) for that customer owner and place that total in column F for that customer owner ID in that row

    Again, expectation is that there will be duplicate values in columns E and F where a customer owner has more than one customer. I have attached a sample workbook that demonstrates the expected results in columns E and F. Note the actual workbook will not necessarily have the data in adjacent columns, so absolute references are likely preferred (as if I know what I'm even talking about! ).

    Thanks so much and please let know if I can clarify anything better than I have here already.

    Regards,
    Chris
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

    You dont need VBA for this.

    put this in E2, and copy down amd across...
    =SUMIF($B$2:$B$32,$B2,C$2:C$32)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

    Thanks for the quick reply Ford! I'm working in a workbook with over 500K rows of data, I'm concerned about the time it might take to run a formula like this for each lookup value. I'm not at work right now, so I can't try it until tomorrow. Do you think it will not be a problem with that many rows? I'm a little gun shy since I tried something simlar with an array formula once before and it would literally take hours (like overnight!) to run. Any feedback is appreciated.

    Thanks!
    Chris

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

    That is a regulat formula and should not slow things down that much. depending on what the ARRAY formula was, it may have been dynamic, meaning it would get calc'd any time any change was made to the WB. I suggest give it a shot and see what happens

  5. #5
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

    Cool, I believe you're right on the calculation as it literally locked up on me many, many times. I'll try it in the morning and post back. I surely don't need elegant for this by any means as I'll turn around and copy/paste as values after getting the results. Appreciate it, thanks again.

  6. #6
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: Excel VBA: Sum Expense/Revenue Data Based on Unique Customer Owner Value

    Good morning Ford...so the formula, as expected, works! That's the good news.

    The bad news, as feared, is that it's moving at a crawl speed to calculate of about 2% every minute and I can't do anything else in Excel while it does its work. This will take hours.

    Any thoughts on a code that might do the same trick in a few seconds or minutes? Appreciate your patience with me.

    Thanks,
    Chris

+ 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. Excel Formula Showing Revenue Recognition Based on Days and Months
    By stratcat3345 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-16-2014, 06:13 AM
  2. Adding Owner Name Based on Account Code in Column A
    By t.tango in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2013, 01:37 PM
  3. [SOLVED] Merge mutliple rows of data based on customer number
    By theatergirl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2012, 08:57 PM
  4. insert revenue or expense based upon date, amount and period
    By shesez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-29-2012, 10:32 PM
  5. [SOLVED] CONVER CSV CUSTOMER DATA TO A CUSTOM INDIVI CUSTOMER PRICE SHEET
    By brunod in forum Excel General
    Replies: 1
    Last Post: 07-07-2006, 02:10 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