+ Reply to Thread
Results 1 to 18 of 18

Copying data from one table column to another if it falls in a specific date range

  1. #1
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Copying data from one table column to another if it falls in a specific date range

    If you look at the attached file. The running total sheet has a table that I will be continuously uploading similar data to for the year. I need to break that data down into each month in separate sheets. The sheet "How March should look" is what I need the sheet "march" to look like after conditional formatting is applied. I need it to copy and paste the part number column from the table in running total to the part number column in the table in the march sheet. But I only need the part numbers that occur in march. I then need the subsequent descriptions and costs to be copied over for those part numbers. I found one formula that somewhat worked but it left 0s in the cells for which the part number did not exist in march date range. I would like for all of this to happen automatically as I load data in the running total table.

    Thank you
    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,168

    Re: Copying data from one table column to another if it falls in a specific date range

    Hi fireking,

    You need to learn about Advanced Filters and using a Date Range. Look at this site for some examples:

    http://www.contextures.com/xladvfilter01.html
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    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: Copying data from one table column to another if it falls in a specific date range

    I have closed your other thread, please dont open duplicate thread - you can continue here
    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

  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: Copying data from one table column to another if it falls in a specific date range

    Try this ARRAY formula in A2...
    =IFERROR(INDEX('Running Total'!A:A,SMALL(IF(('Running Total'!$E$2:$E$9>=March!$I$1)*('Running Total'!$E$2:$E$9<=March!$J$1),ROW('Running Total'!$A$2:$A$9)),ROWS($A$1:A1))),"")
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Copy across, then copy down as needed

  5. #5
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Copying data from one table column to another if it falls in a specific date range

    I was able to get close with this, but not exactly what I need. Could you go more in depth with how I should set up this filter?

  6. #6
    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: Copying data from one table column to another if it falls in a specific date range

    So you actually want a unique list of parts, then sum the QTY?

  7. #7
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Copying data from one table column to another if it falls in a specific date range

    Yes, this is a very simplified version of a project for work. I have a macro I will run that will remove the duplicates after I have the part numbers that occurred in each month.

  8. #8
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Copying data from one table column to another if it falls in a specific date range

    This will only return the first row of the table on the running total sheet,and that part number does not occur in march.

  9. #9
    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: Copying data from one table column to another if it falls in a specific date range

    OK so you will end up with a list of unique part numbers for March anyway?
    If not, would you consider adding a helper column to your Total sheet? I will then use this to pull unique parts, based on your dates, and then sum the qty

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

    Re: Copying data from one table column to another if it falls in a specific date range

    Hi fireking,

    See the attached where I did an Advanced Filter using the link I showed above. Then after the filter, I used a Pivot Table to get what I think you wanted as an answer.

    Advanced Filter and then Pivot.xlsx

  11. #11
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Copying data from one table column to another if it falls in a specific date range

    This is close, but I need the table on "march" to be linked to the table on running total. Where the part #s are automattically added if they fall in to that month. And then continues to do so as more data is entered, as I will be doing this for each month

  12. #12
    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: Copying data from one table column to another if it falls in a specific date range

    So, would you be OK with using a helper column?

  13. #13
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Copying data from one table column to another if it falls in a specific date range

    Yes, if it can be hidden.

  14. #14
    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: Copying data from one table column to another if it falls in a specific date range

    Yup, you can hide it.

    in Total sheet...
    F2=COUNTIF($A$2:A2,A2)
    copied down
    in March...
    A2=IFERROR(INDEX('Running Total'!A:A,SMALL(IF(('Running Total'!$F$2:$F$9=1)*('Running Total'!$E$2:$E$9>=March!$I$1)*('Running Total'!$E$2:$E$9<=March!$J$1),ROW('Running Total'!$A$2:$A$9)),ROWS($A$1:A1))),"")

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Your SUMIFS formula should now work, just add this to the start...
    if(A2="","",your-formula)

    For the Cost...
    D2=IF(A2="","",VLOOKUP(A2,'How "March" should look'!$A$2:$E$5,4,0))

    Note that this will retun the values based on the very 1st match. If the cost changes later, we will need to revise that

  15. #15
    Registered User
    Join Date
    09-02-2013
    Location
    wellington, new zealand
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Copying data from one table column to another if it falls in a specific date range

    I may have attached your excel file, now macro enabled, (first time so anything could happen)
    You will see it has another sheet "March_1".

    This sheet has a macro attached which will run every time you select the sheet.

    To create other months copy the sheet and change the dates.

    It is very basic in order to, perhaps, make it easier for you to follow.

    there is no validation against the part number and unit cost (It will use the first instance of the unit cost)

    If you don't like it running when you open the sheet then move all the code to a module and add a button to drive it.

    Good luck
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    06-21-2018
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2013
    Posts
    12

    Re: Copying data from one table column to another if it falls in a specific date range

    This is great, but I need to build my own spreadsheet at work. Could you give me an overview of how you recorded this macro?

  17. #17
    Registered User
    Join Date
    09-02-2013
    Location
    wellington, new zealand
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Copying data from one table column to another if it falls in a specific date range

    Quote Originally Posted by fireking14 View Post
    This is great, but I need to build my own spreadsheet at work. Could you give me an overview of how you recorded this macro?
    Hi fireking14
    There is nothing recorded in this macro it was constructed by hand.

    I started by getting the dates and storing them in a variable.
    You can get an idea of the code by recording select the dates and copying to another cell. You, obviously do not want to do a copy but it will show you how to address a cell.

    As the method, I chose, to combine like part numbers required looking for previous occurrences each run had to start with an empty sheet otherwise each time it runs it adds the same pars to itself.
    Therefore the next bit is to clear all the data after the header row. There are heaps of ways to do that and you could record selecting A2 the shift >cntl > end keys and pressing delete.

    I then needed to know how many rows there are on the input sheet to control the loop.
    You could possibly record selecting the top left of your input to the bottom left of your input.

    What you need from this is the row number.

    I then set up some variables to keep track of or the input and output rows.

    I then created a loop starting with the first data row on the input sheet
    First checking the data is within the range on the output sheet.
    If not go to the next row.

    When I find a compliant record (within the date range) on the input sheet I look on the output sheet to see I have seen that part number before

    If I have then I add the occurrence value from input to existing value on the output and also perform the multiplication although you could leave this as a formula

    If there is no previous occurrence then I add a new line copying the required data from input to output and perform the calculation cost x occurrence.
    Also, this step adds 1 to the variable holding the location of the next available output line.

    Option Explicit

    Please Login or Register  to view this content.

  18. #18
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Copying data from one table column to another if it falls in a specific date range

    ARRAY formula in A2.
    Please Login or Register  to view this content.
    In B2 and D2 normal formulas are used . Pl see file.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

+ 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. Replies: 2
    Last Post: 07-15-2018, 06:27 PM
  2. check in which range a date falls and return a specific value
    By beltzer in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2016, 04:29 PM
  3. Replies: 1
    Last Post: 11-13-2015, 04:58 PM
  4. [SOLVED] Date Day and Month Reverse When Copying Data from a Range To A Table using an Array
    By TheScott in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-29-2015, 06:22 PM
  5. Matching Data that falls within a specific date range
    By Alexg1589 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-03-2014, 02:32 PM
  6. [SOLVED] Formula to assign specific numbers if a date falls within a certain date range
    By headley4ever in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-24-2014, 04:16 PM
  7. Replies: 1
    Last Post: 07-19-2006, 09:40 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