+ Reply to Thread
Results 1 to 14 of 14

Exclude rows of data from a lookup

  1. #1
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Question Exclude rows of data from a lookup

    I've been using a combination of VLOOKUPs and consequent HLOOKUPS to get the data I need, but as my data set increases in size I'd like to reduce the amount of data held in an "At a Glance" style table.

    Essentially what I am looking for is to take all of the data from the below example table, headers are on the leftmost column due to the way the spreadsheet is layed out, and put them into an auto updating table on a separate sheet, but I would like to exclude all instances of "Completed" from this second table. I cannot simply remove these values from the first table as they are required for reporting in other areas of the workbook.

    So table one looks like this:

    ID 1 2 3 4 5
    REF 0152 0197 0258 0269 0270
    Assigned Date 01-Dec 02-Dec 03-Dec 04-Dec 05-Dec
    Status Completed In Service In Progress Completed Assigned

    and table two should look this this
    ID REF Status
    2 0197 In Service
    3 0258 In Progress
    5 0270 Assigned

    I'd like to acheive this in an automated fashion, with no blank rows in the second table if possible. And I'd like to keep away from doing this in VBA if possible too.

    I think I need to use a combination of the IF, SMALL, INDEX and MATCH functions, but this is more advanced formulae than I've written so far and I'm struggling to make sense of any tutorials I've found online.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    Hi and welcome to the forum!

    Assuming table one is in Sheet1 A1:F4 (with headers in column A), this array** formula, copied down and across to cover two columns will give you the desired ID and REF returns:

    =IFERROR(INDEX(Sheet1!$B$1:$F$4,COLUMNS($A:A),SMALL(IF(Sheet1!$B$4:$F$4<>"Completed",COLUMN(Sheet1!$B$4:$F$4)-MIN(COLUMN(Sheet1!$B$4:$F$4))+1),ROWS($1:1))),"")

    It would work for the Status as well, though I notice that you're not wanting to return the Assigned Date, so the formula in your third column will need to be:

    =IFERROR(INDEX(Sheet1!$B$1:$F$4,COLUMNS($A:D),SMALL(IF(Sheet1!$B$4:$F$4<>"Completed",COLUMN(Sheet1!$B$4:$F$4)-MIN(COLUMN(Sheet1!$B$4:$F$4))+1),ROWS($1:1))),"")

    Regards

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Exclude rows of data from a lookup

    Fantastic! Works a treat. The only issue I have now is that the bottom of the table is returning a value of 0. The data I provided was an example of the data I'm using, the actual data I can't show for data security reasons, but where I've copied the information across to include the full data set I'm getting 0's where the formula you've provided isn't. The formula I have is (entered as an array):

    =IFERROR(INDEX(Projects!$1:$8,COLUMNS($B:B),SMALL(IF(Projects!$8:$8<>"Completed",COLUMN(Projects!$8:$8)-MIN(COLUMN(Projects!$8:$8))+1),ROWS($1:2))),"")

    This returns all of the correct data, but as I say, is giving me 0's at the end of my table, which is causing issues with other lookups I have running so I can't simply hide these with conditional formatting.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    Why did you decide to omit the column references when you translated my formula? For example:

    Projects!$1:$8

    and not (guessing):

    Projects!$A$1:$E$8

    Are you aware of the significance of this in Excel? And also of the potential difference in results it may cause?

    Regards
    Last edited by XOR LX; 12-09-2013 at 11:59 AM.

  5. #5
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Exclude rows of data from a lookup

    My apologies, I hadn't specifically omitted the column references. I had tried to build in some future proofing by changing the references to $A$1:$XFD$8, to include all of the possible cells that could be used to house the data in question.

    I'm not aware of the potential difference in results though, I'd very much appreciate a brief explanation if you wouldn't mind?

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    Firstly, have you actually corrected the references now? If so, were the results what you expected?

    Secondly, referencing entire columns or rows in array formulas is not advisable (and certainly not an entire sheet!) Surely you can some up with some suitable upper limits for the row and column of the data range? Or, if you need the ranges to be dynamic, we can arrange that as well.

    Regards

  7. #7
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Exclude rows of data from a lookup

    I have amended the references to stop at the end of the data and yes, this fixes my problem, however increasing it by just one column is giving me the same error.

    I hadn't realised referencing an entire column/row wasn't advisable in an array formula, I'll keep this in mind in future.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    Ok. The best thing to do would be to set up your range dynamically, so that it responds to additions/deletions in the dataset, and determines the last-used row and column within that range. This negates the need for you to set arbitrarily large range references and also maximises the formula efficiency.

    Let me know if you're interested - though for this it would be much easier if a sample workbook were available.

    Regards
    Last edited by XOR LX; 12-09-2013 at 01:10 PM.

  9. #9
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Exclude rows of data from a lookup

    I would be very grateful for some assistance in setting up dynamic ranges, I've attached a sample workbook, I hope this is enough information.

    Sample Workbook.xlsx
    Attached Files Attached Files

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    Sure. Looking at your sample, am I correct in thinking that it will only be the columns that will change? And that the rows will always be fixed, i.e. 1 to 8 in this example, with the Status in the very last of these?

    Regards

  11. #11
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Exclude rows of data from a lookup

    That's right, the columns will be added to over time, but the rows will always be the same.

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    Hi,

    If you go to Name Manager and create a new name, Project_Data say, and enter this in the Refers to: box:

    =Projects!$A$1:INDEX(Projects!$8:$8,,MATCH(REPT("z",255),Projects!$1:$1))

    Exit Name Manager.

    As per the attached, the formula in B2 now becomes:

    =IFERROR(INDEX(Project_Data,COLUMNS($B:B),SMALL(IF(INDEX(Project_Data,8,)<>"Completed",COLUMN(Project_Data)-MIN(COLUMN(Project_Data))+1),ROWS($1:2))),"")

    Notes

    Once you've set up the Named Range, then (unless you've maximised the Name Manager window) highlighting the Refers to: part will put borders around the appropriate range in the sheet. This should currently be equal to A1:F8 in your attachment, and will expand/contract as you add/delete new columns (please check).

    The parts you may need to amend to suit your actual spreadsheet are:

    Projects!$A$1 should be the upper-left cell in the range.
    Projects!$1:$1 and Projects!$8:$8 refer to the first and last rows in that range respectively.

    The formula also depends upon the entries in the top row (i.e. Company 1, Company 2, ...etc.) being textual, and may fail if they are in fact numeric (though I can't imagine this being the case).

    Hope that helps. Let me know if you need any more assistance.

    Regards

  13. #13
    Registered User
    Join Date
    12-09-2013
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Exclude rows of data from a lookup

    Thank you so much for your help, it has been utterly invaluable!

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Exclude rows of data from a lookup

    You're welcome! And best of luck with the project.

    Regards

+ 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. Selection of loop data, move copy and paste data, and exclude blank rows
    By mav02004 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2013, 10:20 AM
  2. Exclude certain rows from VBA Code
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-28-2011, 07:08 AM
  3. Exclude rows from Autofilter!
    By BDHogan in forum Excel General
    Replies: 5
    Last Post: 05-07-2008, 03:40 AM
  4. Exclude Rows that are hidden from SUM
    By markdc01 in forum Excel General
    Replies: 8
    Last Post: 01-21-2007, 05:12 PM
  5. Copy rows, but exclude blank rows
    By Mary in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2005, 04:05 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