+ Reply to Thread
Results 1 to 12 of 12

Extract of data based on specific criteria

  1. #1
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Extract of data based on specific criteria

    I have a macro enabled workbook. The main worksheet, Year 2019, is made up of rows for the complete year. For example:

    Col A

    01Jan19
    to 31Jan19

    01Feb19
    to 28Feb19

    TO

    01Dec19
    to 31Dec19


    The format of this date field is nnmmmnn

    i wish extract all rows for a given month to another workbook eg jan or feb or dec. so as there are 31 rows for January I end up with 31 rows in the other workbook with only the selected columns from the year 2019 worksheet and these rows to be updated automatically when the main worksheet, year 2019, is updated.


    There are around 12 columns but the main columns I wish to be also copied to the new workbook are ;

    COLA COL D COL F COL H COL I COL M
    start date - subject - who booked - start time - end time - description

    These key columns are either text or date or time formatted.

    can anyone assist in providing a formula to achieve this.

    thank you for your consideration.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    22,163

    Re: Extract of data based on specific criteria

    It would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post. Don't try to use the Paperclip icon, as it doesn't work on this forum.

    Pete

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland
    MS-Off Ver
    µSoft Office 365. Learning Excel all over again!!
    Posts
    31,905

    Re: Extract of data based on specific criteria

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually).

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn



  4. #4
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Re: Extract of data based on specific criteria

    Thank you for responding so quickly. I attach an example of the data - obviously sanitised. This is in worksheet Year 2019.

    I have also created example worksheets - Jan / Mar / Dec with the required column headings and where the data should be extracted from on sheet year 2019.

    Each day in the month may have +/- 6 rows

    Would it also be possible to make the formula not year dependant to support year rollover?

    Thanks again.
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland
    MS-Off Ver
    µSoft Office 365. Learning Excel all over again!!
    Posts
    31,905

    Re: Extract of data based on specific criteria

    Use this in A2 of Jan, with similar formulae elsewhere on the sheet and in other sheets:

    =INDEX('Year 2019'!D:D,AGGREGATE(15,6,ROW('Year 2019'!$A$2:$A$100)/(TEXT('Year 2019'!$A$2:$A$100,"mmm")="Jan"),ROWS($1:1)))&""

    done only for January
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Re: Extract of data based on specific criteria

    Glen, thank you for the formula. The formula extracts the contents for text data. However, for cells that contain a date and / or time data I just get a number. I have formatted the cells with a date format and time format I require but the formula appears to be overriding the cell contents that have been formatted with either ddmmmyy or hh:mm.

    Also, when the formula no longer finds the specified month I get a #num! entry?

    Thank you for your assistance and time.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland
    MS-Off Ver
    µSoft Office 365. Learning Excel all over again!!
    Posts
    31,905

    Re: Extract of data based on specific criteria

    The number IS the date / time. Reformat the cells AFTER applying the formula.

    Not sure what you mean by "Also, when the formula no longer finds the specified month I get a #num! entry?" as A21 to G29 all contain the various formulae, but are BLANK as there are no more values to return.
    "

  8. #8
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Re: Extract of data based on specific criteria

    Glen, I have copied the formulas you very kindly provided to the 'Mar' worksheet. I have changed 'jan' for 'mar'. See attached.
    In column A in your 'jan' example once the formula cannot find the month of 'jan' it returns a 'blank' / empty cell which is great. However, in the 'Mar' worksheet it returns a #num! when it cannot find 'mar'. Obviously the other formulas have an if statement based on the results in column A.

    I must be doing something wrong as your solutions works ok for Jan but not another month. Can you please assist. Thank you.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland
    MS-Off Ver
    µSoft Office 365. Learning Excel all over again!!
    Posts
    31,905

    Re: Extract of data based on specific criteria

    Im back in a couple of hours...
    ..

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... based in Ireland
    MS-Off Ver
    µSoft Office 365. Learning Excel all over again!!
    Posts
    31,905

    Re: Extract of data based on specific criteria

    Change A2 to:

    =IFERROR(INDEX('Year 2019'!D:D,AGGREGATE(15,6,ROW('Year 2019'!$A$2:$A$100)/(TEXT('Year 2019'!$A$2:$A$100,"mmm")="Mar"),ROWS($1:1)))&"","")

    I'm not 100% sure why it didn't need this for jan... but....

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Re: Extract of data based on specific criteria

    Glenn, thank you so much. This appears to be working just great. I will do some more testing.

    Glenn may I ask another question. If I wanted to hold the extracted data from worksheet Year 2019 in another workbook for any given month how would the formula need to change. Thanks again.

  12. #12
    Registered User
    Join Date
    02-27-2016
    Location
    London, england
    MS-Off Ver
    2019
    Posts
    61

    Re: Extract of data based on specific criteria

    This has been resolved. Thank you very much for your time and effort.

+ 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] if formula based on several criteria to extract data based on conditions
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-17-2018, 12:46 PM
  2. [SOLVED] Extract values from a database based on a specific criteria
    By Charli53 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2017, 03:35 AM
  3. Replies: 0
    Last Post: 05-02-2016, 07:59 AM
  4. Replies: 3
    Last Post: 12-18-2014, 10:27 AM
  5. [SOLVED] Extract Specific Data from range dependant on text criteria
    By Grimace in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 07-09-2013, 08:43 PM
  6. Using formulas to extract data meeting 2 specific criteria
    By Levie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-01-2012, 09:27 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