+ Reply to Thread
Results 1 to 7 of 7

Read data in one table, then distribute and sum it in another table

  1. #1
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Read data in one table, then distribute and sum it in another table

    Hello -

    I'm not an Excel power user. I need a formula or VBA strategy to progressively go through departmental vacation entries in one table (start dates and end dates), and incrementally transfer and sum it by week and dept into another table in a different sheet. I have written VBA code to generate the 2 sheets contained in my simplified example file. Now I want to translate all the table entries in the "Data" sheet t to the table in the "Summary" sheet, organized by "Week Of" and "Department". Not sure if I need VBA or not. A big issue is that I'm not sure how to represent/account for the weeks between the start week and end week, since they are not explicitly given in the first table. It seems like I need to use loops, but that could get ugly and slow if I have to do it cell by cell for the table in the "Summary" sheet. Is there a more elegant approach, like using arrays? I'm not super familiar with arrays, so if that's a good choice a brief rationale for using them would be appreciated.

    Ultimately I will read data from the resulting table to another workbook, where week by week dept headcount analysis takes place, so I want to represent all weeks between the first and last weeks in the table, even if they contain zeroes.

    Thanks in advance for your help!

    PWM
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Read data in one table, then distribute and sum it in another table

    Hi PWM,

    I'm not sure I understand the column headings but see if the attached Pivot Table does what you want. You can group the dates by weeks.

    DeptTimeOffSummary Pivot Table.xlsx

    Note - no formulas needed just drag column headings into the Pivot Table.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Read data in one table, then distribute and sum it in another table

    Hi Marvin - thanks for your help. I had thought about Pivot Tables but I don't think it will work.

    Take the first entry for example: a vacation with startdate 8/31/2018 and end date 9/14/2018. The pivot table records that entry as a "1" on Aug 27 under dept "Bakery". However, there's more data that isn't being represented. That one vacation consists of:
    1. 1 day off on Fri 8/31 in the "week of" 8/27 (FDOWO = 8/27- I have a key for the meaning of the headers below the first table.)
    2. 5 days off the last "week of" which is week of 9/10
    3. 5 days off the week between 8/27 and 9/10, which is week of 9/3 - this is one of the problems I have in that this week isn't explicitly represented in the table anywhere

    So in addition to the 1 day for week of Aug 27 under Bakery, there should also be 5 days for week of 9/10 under Bakery and 5 days for week of 9/3 under Bakery. That's a total of 11 business days of vacation. So I don't think the PivotTable approach can get to this.

    Plus, in the third entry, which is for a separate Bakery entry, there is another day of vacation in week of 9/3 which would need to be added to the 5 days from the first entry, totally 6 days off week of 9/3 in the Bakery dept.

    I find this really complex, and not sure what approach could allow me to add the data for each entry to the new table, and then revise that data as necessary as subsequent entries in the first table are parsed.

    Any additional idea you or anyone else has would certainly be appreciated.

    Thanks,
    Patrick

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Read data in one table, then distribute and sum it in another table

    Hey Patrick,

    Most of the time these scheduling problems need help in "collecting the data". Instead of a start date and how many days, you should put down each date the employee is out. If a person was out for 4 days, you should have 4 rows of data. What if they worked in the Bakery for 2 of those days and in another spot the other two days? If you had the data as one row per person and had the department they worked in also in that row, a Pivot Table would easily solve your problem. This topic is discussed in articles of Crosstab vs Tabular data. There are Excel tools to "UnPivot" the Crosstab table back to a Tabular table so Excel can work with it much easier. I suggest you do this with your data.

    https://www.excel-university.com/unpivot-excel-data/

    I suggest you expand your data and leave out the start of week date and only use the date the employee is out. Also - your column headings are a little confusing. I really don't know what they mean. This kept me from giving a better answer.

    See if that makes sense and if not then keep asking.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Read data in one table, then distribute and sum it in another table

    The headers are a bit confusing to me as well. This doesn't take days off into consideration for right now, but see if it gives you some ideas. If it helps then maybe you can enlighten me on how the days off might be accounted for.

    This formula in 'Summary'
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  6. #6
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Read data in one table, then distribute and sum it in another table

    Hi MarvinP and FlameRetired - thank you for your replies, and I apologize for not acknowledging them sooner. As it turned out, MarvinP's reply got me on a better track, and the article he links to is both supersimple, yet profound especially if you're new to VBA. I was just accepting that the data I was receiving (a legacy of an Outlook workflow with only start and end dates specified) was what I had to deal with, and made the rookie mistake of trying to make my code conform to it. Rather than that, the article reminded me that a key part of strategy is to step back and assess the data, and then MANIPULATE it into a form that makes everything easier downstream. The idea of flat, tabular data was something I "sort of" understood but not really in the explicit manner that the article articulates. Thanks for setting me on a better path, and I appreciate your help! Not sure if I should mark this thread as solved? Again, thanks for the help. PWM

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,807

    Re: Read data in one table, then distribute and sum it in another table

    Yes, you should mark it as solved, please.

    Please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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] Vlookup/Match - Read Data from 1 table using a value from another
    By oblah in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-17-2017, 12:11 PM
  2. Distribute data from Single entry table to Multiple Workbooks
    By noront in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-07-2016, 09:46 AM
  3. Drop down box to read data from a table?
    By d3ell in forum Excel General
    Replies: 3
    Last Post: 01-20-2012, 10:49 PM
  4. Replies: 4
    Last Post: 11-10-2011, 04:43 AM
  5. Excel 2007 : How to Read RSS/XML into Data Table?
    By ice1000 in forum Excel General
    Replies: 0
    Last Post: 06-25-2011, 07:10 PM
  6. Help with userform (trying to read data from table into combo list)
    By EK1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2010, 10:18 AM
  7. Replies: 1
    Last Post: 02-19-2009, 03:00 AM

Tags for this Thread

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