+ Reply to Thread
Results 1 to 8 of 8

Extract records based on criteria

  1. #1
    Registered User
    Join Date
    12-01-2008
    Location
    India
    MS-Off Ver
    Microsoft 365 Enterprise - Excel version2301
    Posts
    63

    Extract records based on criteria

    Hi All,


    I have a list containing numerous records. There are many fields, One of the field in the record is "CODE" there are different codes in this field, all i want to do is fetch only specific field of the record pertaining to CODE = 105, 106 and 109, on a separate sheet, i want to have a macro so that i can fetch the records, it should search all the code one by one until the Code list ends.


    Thanks in advance
    Attached Files Attached Files
    Last edited by Amarjeet Singh; 01-12-2009 at 03:40 AM. Reason: solved

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Why do you need a macro?
    You can achieve this with the standard Data Filtering functionality of Excel.
    If your unfamiliar with this, check out the Excel Help on the subject. If you still have problems, post back.

    Rgds

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    To add to Richard's comment,

    With 3 (or more) criteria it can be easier to add a "helper column" & perform the filtering on that column before copying & pasting the visible rows to the result sheet.

    An example of a helper formula for this example would be to create a new "Reference Table" sheet (or section on current sheet) with the list of codes to filter for & then enter the below formula into column I.

    Please Login or Register  to view this content.

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Registered User
    Join Date
    12-01-2008
    Location
    India
    MS-Off Ver
    Microsoft 365 Enterprise - Excel version2301
    Posts
    63

    Thanks

    But how i can i avoid unwanted columns then? i dont want to manually delete the columns as there are many columns , is it possible to fetch the data based on column heading?


    thanks

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    See the attached workbook.

    I have added three names. "Data" which covers your original data in A1:H22 of the Problem sheet, "DataOut" which is A1:E1 of the results sheet, and "Criteria" which is G1:G4 of the results sheet.

    Now erase the filtered data in A2:E13 of the results sheet so that we can demonstrate the filtering.

    From the Menu choose Data Filter Advanced Filter. In the 'List Range' box enter the name 'Data', in the 'Criteria Range' box enter 'Criteria' and in the Copy To box enter 'DataOut' then press OK.

    HTH
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-01-2008
    Location
    India
    MS-Off Ver
    Microsoft 365 Enterprise - Excel version2301
    Posts
    63

    Thanks

    Great ! its working one more thing is it possible to make the "DATA" Input range dynamic, so that it can adjust itself according to the range of Input data.

    Thanks once again.

  7. #7
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Go to Insert - Name - Define
    Click on Data
    In the "Refers To" box insert : =OFFSET(Problem!$A$1;0;0;COUNTA(Problem!$A:$A);8) instead of the existing range

  8. #8
    Registered User
    Join Date
    12-01-2008
    Location
    India
    MS-Off Ver
    Microsoft 365 Enterprise - Excel version2301
    Posts
    63

    solved

    Thanks all.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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