+ Reply to Thread
Results 1 to 17 of 17

How to extract data from range to a new worksheet if it fits 2 criteria

  1. #1
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    How to extract data from range to a new worksheet if it fits 2 criteria

    So bit more info about my Workbook. So I created a workbook to use for ordering alcohol stock where I input how much we have and with the help of a few formulas it compares it to the par levels and gives me an answer of how many I should order. The problem arises when i have number of suppliers and have to analyse the data and order products with all the information in front of me. My question is can i extract data into different worksheets so each worksheet is sorted by supplier. For example the table below is an example of my worksheet1, and I would like worksheet2 to show me everything I need to order from supplier1 but miss out anything that might have a "0" in the order in column ie the row whiskey. Sorry if this is confusing to understand so please ask for any more info.

    Thank you.

    Product Supplier Order In Par Level Total Have
    Vodka Supplier1 5 10 5
    Gin Supplier 2 2 10 8
    Rum Supplier1 3 10 7
    Whiskey Supplier 1 0 10 15

  2. #2
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Hello DrewBoid,

    Welcome to the forum

    To shortly answer your question, yes, you can do so by using Array Formula, normal Formula with conditions, or VBA - VBA will be a much better approach if your data goes into the range of thousands of rows.

    Here is a sample workbook with your provided data with some additional dummy data, to show you how an approach with INDIRECT will look like.
    This approach emphasizes on performance, but it requires you to sort Master List by Supplier (Column B) and by Order in (Column C, Largest to Smallest)

    I think VBA will be a much better solution if you have something like, 20 suppliers, and you want each of them on a new sheet lol. Or you can set it up so all you need is to type the Supplier name on the Sheet 2 and it will find it for you (Manually printing)
    Attached Files Attached Files
    (copy pasta from Ford)
    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

    Regards,
    Lem

  3. #3
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Thank you for your response. I am using a mac so VBA is not an option. Thank you again

  4. #4
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    II've attached my order form as I'm still having problems. Your solution worked on your workbook but not on mine. It might be to do with merged cells and headings and stuff. Please shed light on this and any hep would be great. Thank you again.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    The problem with your data is that you have those header rows, which will be a mess when you sort to use Indirect xd

    To keep your Master List as intact as possible, here is your file with Array Formula
    Please Login or Register  to view this content.
    Because it is an Array formula, remember to confirm it with Ctrl-Shift-Enter, not just Enter. A simple way to do this is to paste the formula in the cell, then click on the formula bar, hold Ctrl-Shift and hit Enter. If the formula is wrapped inside a { } afterward, then you did it right.

    The Formula is for cell A2, applied from A2 to I400, with 2 simple helper cells which are:
    J2: Simply the name of the supplier you wanna check and
    K2: =COUNTIF('Stock Take Wet Stock'!$B$6:$B$394,$J$2)
    Counting how many rows that has that Supplier's name (For reference, checking and whatsnot)

    Unfortunately, you will still need to filter out rows with 0 value on Order in Column. I'll see what I can do to counter this, chances are the formula will get pretty big lol

    Simply change the name in J2 (Supplier1, Supplier2, etc) and watch as the file changes itself. I've applied formula up to row 400, if your Master List gets bigger, you might wanna drag the formula from A400:I400 down to match your Maste List.

    Edit: Removed old sample, added a better one in the post below this one.
    Last edited by Lemice; 06-13-2016 at 12:43 AM.

  6. #6
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    As soon as I editted my post, I found the solution to the 0 (Curse you AND function)

    Here is the improved Array Formula:
    Please Login or Register  to view this content.
    I also added in 1 more helper cell to show you how many results there are (So you can easily calculate how many orders from that Supplier is 0)

    And here is the sample file with it. Please still read the post above this one still.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    It works perfectly and now i understand the formula more. what does the iferror formula do? does

  8. #8
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    You can remove the Iferror and you will see that at the end of the list, instead of "blank" value, there will be errors

    The format of Iferror is

    IFERROR(Something, Value if Something is an error)

    In this case, that Something is our formula, and the Value if Something is an error is "" (blank value if error). It will return the entire value of Something if it is not an error.

    For example, there are only 80 rows with Supplier6 name on it, and the row number 82 was forced to return the row 82nd that has the name Supplier6. It doesns't exist, thus returning an Error. The Iferror in front of it is to prevent that case, which will return a "" value if the formula in it returns an error.

    In short, it's there to prevent cases where nothing was found basing on the conditions of the formula (Matching Supplier's name, Order in must not be 0, etc)

    Of course, if the formula returns a non-error value, then that's great, Iferror will return just that.

    If you want me to break down any part of the formula, let me know.
    Last edited by Lemice; 06-13-2016 at 01:54 AM. Reason: Coloured. My eyes!

  9. #9
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Thank you very much for your help. One more thing, how come if I add more rows above the header row in the second sheet why does some of the items go missing? What do I need to change in the formula? I can't seem to work out which absolute reference I need to change

  10. #10
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Change the following thing

    {=IFERROR(INDEX('Stock Take Wet Stock'!A$1:A$394,SMALL(IF(('Stock Take Wet Stock'!$C$1:$C$394<>0)*('Stock Take Wet Stock'!$B$1:$B$394=$J$2),ROW('Stock Take Wet Stock'!$B$1:$B$394)),ROW()-1)),"")}

    ROW() will return the number of the row the formula is in. If you want to move the first row with formula down to row 5 for example, make sure that ROW()-1 on that row have to return 1, since it will take the first result, so change the formula to

    {=IFERROR(INDEX('Stock Take Wet Stock'!A$1:A$394,SMALL(IF(('Stock Take Wet Stock'!$C$1:$C$394<>0)*('Stock Take Wet Stock'!$B$1:$B$394=$J$2),ROW('Stock Take Wet Stock'!$B$1:$B$394)),ROW()-4)),"")}

    (This is for row 5)

    So, row 3? ROW()-2. What about row 7? ROW()-6

  11. #11
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Also you know the helper cell K2 with the formula K2: =COUNTIF('Stock Take Wet Stock'!$B$6:$B$394,$J$2) why does it come back with one less amount of items from that supplier?

  12. #12
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    It should not be, because that function counts the number of times the value in J2, aka Supplier's name, appears in a row, unless your real data's range is not from B6 to B394 but bigger.

    Scratch that, for some reason, when I do filter on Supplier, I found 2 Suppler2 which are
    "Supplier2"
    "Supplier2 " (Found in B113)

    You see what's going on? For some reason, somewhere in there, there is a trailing character at the end. For some reason, TRIM does not work on it on my end, you might want to do a forced counting / manually fixing those values.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Try this which should remove problems of adding/deleting rows

    =IFERROR(INDEX('Stock Take Wet stock'!A$1:A$394,SMALL(IF(('Stock Take Wet stock'!$C$1:$C$394<>0)*('Stock Take Wet stock'!$B$1:$B$394=$J$2),ROW('Stock Take Wet stock'!$B$1:$B$394)-ROW('Stock Take Wet stock'!$B$1)+1,""),ROWS($A1:A1))),"")

  14. #14
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Thanks Lemice i will have a look at that and thank you for all your help.

    Thanks JohnTopley but it didn't work it just give me the same value when i drag the formula.

    Also what part of the formula would I have to change if I decided to add more items on the main worksheet? Would it be the range or data?

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    My typo ....

    =IFERROR(INDEX('Stock Take Wet stock'!A$1:A$394,SMALL(IF(('Stock Take Wet stock'!$C$1:$C$394<>0)*('Stock Take Wet stock'!$B$1:$B$394=$J$2),ROW('Stock Take Wet stock'!$B$1:$B$394)-ROW('Stock Take Wet stock'!$B$1)+1,""),ROWS($A$1:$A1))),"")

  16. #16
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    ... re adding more items: just extend the range from 394 to your likely maximum. you can do that now as the IFERROR will just return blanks when no data is present.

    e.g.

    =IFERROR(INDEX('Stock Take Wet stock'!A$1:A$500,SMALL(IF(('Stock Take Wet stock'!$C$1:$C$500<>0)*('Stock Take Wet stock'!$B$1:$B$500=$J$2),ROW('Stock Take Wet stock'!$B$1:$B$500)-ROW('Stock Take Wet stock'!$B$1)+1,""),ROWS($A$1:$A1))),"")

  17. #17
    Registered User
    Join Date
    06-12-2016
    Location
    Nottingham
    MS-Off Ver
    2015
    Posts
    9

    Re: How to extract data from range to a new worksheet if it fits 2 criteria

    Thank you very much guys.

    One last thing do you know if there is a non-subscription software for macs like Microsoft Access you can recommend me? I want to create a website like data entry form that is flexible enough to allow me to use images as buttons and use excel as the database software

+ 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] How to test if range selected fits criteria
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2015, 12:40 AM
  2. [SOLVED] Extract value or sum total based on month criteria that falls within Data Range
    By Mysore in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-02-2013, 11:31 PM
  3. Extracting data from column that fits criteria
    By Robo25 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-29-2013, 11:33 AM
  4. [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
  5. [SOLVED] Extract/Copy data within a range based on mutiple criteria?
    By new@excel in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-23-2013, 01:11 AM
  6. Extract data from Excel Worksheet using multiple criteria
    By Beudean Dorin in forum Excel General
    Replies: 0
    Last Post: 03-26-2013, 01:31 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