+ Reply to Thread
Results 1 to 6 of 6

Partial Text String Lookup from a List

  1. #1
    Registered User
    Join Date
    02-23-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    39

    Partial Text String Lookup from a List

    Hi there

    I'm looking for some help on adding the finishing touches to a UK Post Code allocation spreadsheet.

    The data is set up in the following format:

    Depot Number - Depot Name - Telephone Number - Post Codes Covered (The first part of the post code only, all in one cell, seperated by a comma i.e. NW1, NW3 etc)

    How it stands, I have the user type in the start of the post code (K11) that they wish to return the details for and I've used the following array formula to find the result and return in a cell.

    Company Name:
    Please Login or Register  to view this content.
    Telephone Number:
    Please Login or Register  to view this content.
    However, due to the wildcard at the start of the "post code to search", if there is a post code of L5 for one depot, and a post code of AL5 for another depot.

    If I search L5, Excel is returning the first result it finds that contains the string "L5", so if the post code "AL5 is nearer to the starting row, it will return the details for AL5 in error.

    I've tried to remove the wildcard from the start, but this causes a formula error so I'm a bit stuck now.

    Is anyone able to help at all please?

    Thanks in advance!
    Attached Files Attached Files
    Last edited by lookingforhelp1; 01-08-2016 at 09:49 AM. Reason: Added sample workbook

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Partial Text String Lookup from a List

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Cheers!
    Deep Dave

  3. #3
    Registered User
    Join Date
    02-23-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    39

    Re: Partial Text String Lookup from a List

    Thanks, I've attached a sample workbook to my original post.

    What I want to achieve is when "B1" is typed into the search criteria, it should return PERSON B.

    However, because PERSON A has the partial string B1 (BB1), it thinks that this is the result because this is the first string it finds with "B1" in.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Partial Text String Lookup from a List

    Hi lookingforhelp1,

    I think part of your problem is that there are multiple codes in one cell, and the formula finds the first EXACT MATCH using the WildCard Search and both 'B1' and 'BB1' match the search for '*B1*'.

    Doing what you want is beyond my Formula capability, but if VBA is OK, try the attached file which contains the following code. The file uses a UserForm which allows you to search for a partial or exact match (case insensitive). All matching entries are returned in a ListBox. If you 'Double Click' an item in the 'ListBox', the cursor will move to the cell for the 'Person' associated with the Code.

    In UserForm1 code module:
    Please Login or Register  to view this content.
    In ordinary code module ModUserForm1:
    Please Login or Register  to view this content.
    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    To install the software in another file:
    a. Make a backup copy of your file.
    b. Open my file.
    c. Presss ALT F11 to access VBA.
    d. Press CTRL R to accces Project Explorer (if is not already visible).
    e. Right Click the following modules and Export them (will not affect this file):
    (1) ModUserForm1
    (2) UserForm1
    f. Close my file.
    g. Open your file.
    h. Press ALT F11 to access VBA.
    i. Press CTRL R to accces Project Explorer (if is not already visible).
    j. Right Click any module from your file in Project Explorer and import the following modules:
    (1) ModUserForm1
    (2) UserForm1
    k. Create a 'Forms' CommandButton or Create a Shape in your file.
    Developer > Insert > Select 'Forms' CommandButton and Place on Sheet. Assign Macro 'DisplayUserForm1'.
    or
    Insert > Shapes > Select Shape and place on the Sheet. RightClick the Shape and Assign Macro 'DisplayUserForm1'.
    l. Software Installation completed. Save your file.


    To enable Macros and to Run Macros see the following:
    http://office.microsoft.com/en-us/ex...010031071.aspx
    http://office.microsoft.com/en-us/ex...010014113.aspx
    If help is still needed do a google search for 'youtube excel enable macro' and/or 'youtube excel run macro'.


    To access Visual Basic (VBA) see:
    http://www.ablebits.com/office-addin...a-macro-excel/
    a. Click on any cell in the Excel Spreadsheet (may not be needed).
    b. ALT-F11 to get to VBA.
    c. CTRL-R to get project explorer (if it isn't already showing).
    d. Double Click on a 'Module Name' in 'Project Explorer' to see code for that module.

    Lewis
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-23-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    39

    Re: Partial Text String Lookup from a List

    Thanks for your help, I tend to stay away from VBA due to only having limited knowledge.

    I managed to get the goal working by adding a space after the first wildcard though (who'd have thought it!).

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Partial Text String Lookup from a List

    It's an excellent practice to stay within your comfort level.

    Excellent job using the space.

    Here's an idea that may help. Instead of separating the items with commas, separate them with spaces. Make sure you have a space before the first item and a space after the last item.

    Then you can search for ' BB1 ' with a space before and after. You may not need with wildcards.

    Lewis

+ 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] Partial string lookup
    By jprobst in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-14-2015, 08:06 PM
  2. [SOLVED] Lookup Partial String Matches
    By rtabaldi in forum Excel General
    Replies: 5
    Last Post: 04-02-2014, 09:40 PM
  3. Partial String Lookup between two lists of Data
    By rileyfairs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-12-2014, 06:05 PM
  4. Reverse Table Lookup using a partial string
    By pat3white in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-27-2013, 01:35 PM
  5. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  6. Getting info from another workbook based on partial string lookup
    By 96HawkCnvt in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-10-2010, 03:33 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