+ Reply to Thread
Results 1 to 9 of 9

LookUp skipping empty cells and returning first entry

  1. #1
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    LookUp skipping empty cells and returning first entry

    Hi There

    I have a problem where I am trying to do a VlookUp on a certain item (Commodity Code) and it must return other results relevant to that specific item. My problem is that there are empty cells on the returned results of the first entry for that item. VlookUp only looks at the first line for the item. I know that VlookUp must be changed to the functions using Match & Index. However even after a previous post on the same concern I still do not understand how to get it to work. See attached workbook.

    I am using a few user forms to do entries of which only certain information is required based on the relevance. Thus empty cells will always be a part of the workbook. The lookup needs to overlook this.

    Any help will be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: LookUp skipping empty cells and returning first entry

    1) if it's always off by ONE row, meaning the match is to row2 then the data is in row3, then that's easy enough, we'll just +1 on the match.

    2) Note you entered a number 2009045 on the LookupDetails sheet, but on the Data sheet column J is not numbers, it's text. Notice the little green markers in those cells? Excel has noticed this common problem too and is trying to warn you those numbers are not numbers, they are text strings.

    Assuming the text in column J will always be text and we need coerce a match from these non-matching data types, we'll build that into the formula, too.

    4) On LookupDetails, go down column B and remove the colons: from the end of the text, this way the values in those cells match exactly to the text across row 1 on the Data sheet.

    5) Finally, put this formula in C5 and then copy down:

    =INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0)+1, MATCH($B5, Data!$1:$1, 0))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: LookUp skipping empty cells and returning first entry

    Quote Originally Posted by JBeaucaire View Post
    1) if it's always off by ONE row, meaning the match is to row2 then the data is in row3, then that's easy enough, we'll just +1 on the match.
    Thank you for the help thus far. It works provided that the match is in the second row.
    This is however not the case as the results are staggered.

    Can your code be altered so that it looks for the first entry made?

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: LookUp skipping empty cells and returning first entry

    Then TRY
    =IF(ISBLANK(INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0), MATCH(LEFT($B5,LEN(B5)-1), Data!$1:$1, 0))),INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0)+1, MATCH(LEFT($B5,LEN(B5)-1), Data!$1:$1, 0)),INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0), MATCH(LEFT($B5,LEN(B5)-1), Data!$1:$1, 0)))
    and Change
    Loose Piece Material
    Pattern Movement (In/Out)
    Delivery Note
    as
    Loose Piece Material:
    Pattern Movement (In/Out):
    Delivery Note:
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: LookUp skipping empty cells and returning first entry

    Quote Originally Posted by nflsales View Post
    Then TRY
    =IF(ISBLANK(INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0), MATCH(LEFT($B5,LEN(B5)-1), Data!$1:$1, 0))),INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0)+1, MATCH(LEFT($B5,LEN(B5)-1), Data!$1:$1, 0)),INDEX(Data!$1:$1048576, MATCH($C$4&"", Data!$J:$J, 0), MATCH(LEFT($B5,LEN(B5)-1), Data!$1:$1, 0)))
    and Change
    Loose Piece Material
    Pattern Movement (In/Out)
    Delivery Note
    as
    Loose Piece Material:
    Pattern Movement (In/Out):
    Delivery Note:
    The formula works provided the data is in the same format. However when data is staggered the returned values are 0. See new workbook where I have placed extra data in and staggered the needed results all over on different rows.
    Attached Files Attached Files

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: LookUp skipping empty cells and returning first entry

    C5=IFERROR(INDEX(INDEX(Data!$A$1:$X$22,,MATCH(LEFT($B5,LEN($B5)-1),Data!$1:$1,0)),MATCH(0,INDEX(((Data!$J$1:$J$22<>$C$4&"")+(INDEX(Data!$A$1:$X$22,,MATCH(LEFT($B5,LEN($B5)-1),Data!$1:$1,0))=""))*10^10,0),0)),"")
    Try this and copy towards down
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: LookUp skipping empty cells and returning first entry

    Quote Originally Posted by nflsales View Post
    C5=IFERROR(INDEX(INDEX(Data!$A$1:$X$22,,MATCH(LEFT($B5,LEN($B5)-1),Data!$1:$1,0)),MATCH(0,INDEX(((Data!$J$1:$J$22<>$C$4&"")+(INDEX(Data!$A$1:$X$22,,MATCH(LEFT($B5,LEN($B5)-1),Data!$1:$1,0))=""))*10^10,0),0)),"")
    Try this and copy towards down
    Works 100% up until row 22. I changed the code to look at all the rows and now it works for the whole sheet.

    Thank You for the help!!

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: LookUp skipping empty cells and returning first entry

    Glad to help you and thanks for your feedback

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: LookUp skipping empty cells and returning first entry

    Try this if you can...

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * 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. Skipping empty cells
    By CESAR V. ARROYO in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-05-2010, 09:04 PM
  2. Range skipping empty cells
    By CESAR V. ARROYO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2009, 03:33 PM
  3. formulas skipping empty cells
    By Jocote46 in forum Excel General
    Replies: 1
    Last Post: 05-06-2009, 04:09 PM
  4. VLookUp skipping empty cells
    By vsnellman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2007, 10:23 AM
  5. skipping empty cells that are not empty
    By quizkiwi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-03-2005, 02:05 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