+ Reply to Thread
Results 1 to 12 of 12

Lookup where v & hlookup just won't work!

  1. #1
    Registered User
    Join Date
    05-28-2010
    Location
    London
    MS-Off Ver
    MS365 (PC) Version 2301
    Posts
    87

    Lookup where v & hlookup just won't work!

    Hi - thanks in advance to anyone who can help with this! It's taken me over a week off and on to fathom and still I am stuck!

    If you love a challenge then this is for you!

    Basically I have a list of employees who each have a 10 week work rota - some are the same as others but I have over 600 unique rotation plans between 6,000+ staff members

    I have identified what their plan looks like (don't ask me how but I have and I don't want to go back and start again) - I have also identified what the plan they are on is to be called -

    What I can't do is work out who is on which plan

    In short...

    I have a Rotation Plan name with a Rotation Plan description next to it
    Employee numbers with Rotation Plan descriptions next to them
    I need to get the Rotation Plan name next to the employee numbers

    vlookup won't work because the description is too long I believe - it just won't let me do it

    I've tried replacing common characters in the description with numbers so as to create a number and use lookup that way but that won't work either - it gives the same number to different descriptions!

    I hope this is clear

    Attached are the two tabs which I need to relate to eachother - with the Rotation Plan Name in the the PLAN tab next to the Employee Number in the EMPLOYEE tab

    Fire away if not clear

    Thanks again - Paul
    Attached Files Attached Files
    Last edited by Wilgoss; 06-03-2011 at 01:52 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup where v & hlookup just won't work!

    The problem is that Excel will only look at the first 254 characters and you have about 330 there. I took a crack at it using only the first 254 characters. (see attachment). You're going to have to come up with some way of reducing the # (maybe doing a search/replace and removing all periods?). I'm not sure but I believe you'd run into the same problem with VBA methods.
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Lookup where v & hlookup just won't work!

    Does this formula work?

    =INDEX(Plan!$B$3:$WY$3,SUMPRODUCT((Plan!$B$3:$WY$6=Employee!A4)*(COLUMN(Plan!$B$3:$WY$6)-COLUMN(Plan!$B$3)+1)))

    copied down
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    05-28-2010
    Location
    London
    MS-Off Ver
    MS365 (PC) Version 2301
    Posts
    87

    Re: Lookup where v & hlookup just won't work!

    Quote Originally Posted by ChemistB View Post
    The problem is that Excel will only look at the first 254 characters and you have about 330 there. I took a crack at it using only the first 254 characters. (see attachment). You're going to have to come up with some way of reducing the # (maybe doing a search/replace and removing all periods?). I'm not sure but I believe you'd run into the same problem with VBA methods.
    Thanks - I thought I was up against a limit of characters!

    As menitioned in op - I tried replacing the letters with numbers and decimal points with a number to give me a unique number at less than 254 characters in length but I was getting the same numbers duplicated for plans that were different!

  5. #5
    Registered User
    Join Date
    05-28-2010
    Location
    London
    MS-Off Ver
    MS365 (PC) Version 2301
    Posts
    87

    Re: Lookup where v & hlookup just won't work!

    Quote Originally Posted by NBVC View Post
    Does this formula work?

    =INDEX(Plan!$B$3:$WY$3,SUMPRODUCT((Plan!$B$3:$WY$6=Employee!A4)*(COLUMN(Plan!$B$3:$WY$6)-COLUMN(Plan!$B$3)+1)))

    copied down
    I will give that a go on my train journey home
    thanks

  6. #6
    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

    Re: Lookup where v & hlookup just won't work!

    Hi Paul,

    The standard approach would normally be to wrap a MATCH() function inside an INDEX() function. i.e.

    Please Login or Register  to view this content.
    However I suspect this is not working because (most of ) your plan descriptions are in excess of 300 characters and I guess Excel doesn't like this.

    I note that many of the strings are the same at various lengths. For instance at the first 10 characters level, 5793 of the 6326 strings are identical. It may be possible to break these down in some way to overcome what appears to probably be a 256 character restriction.

    If you can give us some idea of the algorithm for producing the plan descriptors it may be possible to do something further.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Lookup where v & hlookup just won't work!

    Hi Wilgoss,

    If you use the leftmost 250 characters of your Rota string things seem to work correctly. There is only 1 duplicate if you truncate the rota string at 250.

    I first deleted duplicates in all rota and came up with a unique list. Then put Plan # next to it to use as a vlookup table. Then one formula was almost good enough except for the strings were too long. Trim to look at only first 250 characters and poof, it worked.

    See the attached for your answer.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Registered User
    Join Date
    05-28-2010
    Location
    London
    MS-Off Ver
    MS365 (PC) Version 2301
    Posts
    87

    Re: Lookup where v & hlookup just won't work!

    Quote Originally Posted by NBVC View Post
    Does this formula work?

    =INDEX(Plan!$B$3:$WY$3,SUMPRODUCT((Plan!$B$3:$WY$6=Employee!A4)*(COLUMN(Plan!$B$3:$WY$6)-COLUMN(Plan!$B$3)+1)))

    copied down
    Thanks - this seems to have worked in all but two rows where I'm getting a #REF! 6051 & 6054

    Any idea why this might be?

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup where v & hlookup just won't work!

    id just bulk replace bbw with say x
    that would drastically reduce string length then repeat with some other string until its reduced to acceptable lengths
    Last edited by martindwilson; 06-02-2011 at 01:55 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Lookup where v & hlookup just won't work!

    It seems those items have 2 occurances in the Plan sheet (column RV and RY) !?? Is that correct?

    Also, if the items are all in 1 row in the Plan sheet, then you can update formula to a slightly more efficient...

    =INDEX(Plan!$B$3:$WY$3,SUMPRODUCT((Plan!$B$4:$WY$4=Employee!A4)*(COLUMN(Plan!$B$4:$WY$4)-COLUMN(Plan!$B$4)+1)))

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Lookup where v & hlookup just won't work!

    If you want the first match, try this instead:

    =INDEX(Plan!$B$3:$WY$3,MIN(IF(Plan!$B$4:$WY$4=A4,COLUMN(Plan!$B$4:$WY$4)-COLUMN(Plan!$B$4)+1)))

    confirmed with CTRL+SHIFT+ENTER, not just ENTER and copied down.

  12. #12
    Registered User
    Join Date
    05-28-2010
    Location
    London
    MS-Off Ver
    MS365 (PC) Version 2301
    Posts
    87

    Re: Lookup where v & hlookup just won't work!

    Thanks to everyone for their help on this - sadly I can't see those icons to click on as a thank you but..


    CHEERS!!!

    Appreciated


    Paul

+ 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