+ Reply to Thread
Results 1 to 6 of 6

Matching IDs to a Database

  1. #1
    Registered User
    Join Date
    12-30-2013
    Location
    Elgin
    MS-Off Ver
    Excel 2013
    Posts
    52

    Matching IDs to a Database

    Hey all, looking for a bit of help. I'm starting to read into VBA, but I'm still unsure of when I should use it. Could I find another way to do this using excel functions?

    Lets say for example, I have a database, about 2000 rows. Column A is a ID #, and column B is a description. I then have a separate excel sheet, that has only descriptions. I want to scan the database, and paste the ID # in to match the descriptions in the separate excel sheet.

    Examples of descriptions:

    Tall red 42 car
    Small red 42 car
    Tall blue 21 truck
    Tall red 81 car

    There are many shared words between descriptions.

    In the database sheet, the description is in one column. However, for the separate search sheet, the descriptions might be broken up so each word has it's own column. I can either format the search sheet so that the descriptions end up in one cell, or write the code so that it searches each column.

    My idea for what needs to happen :
    Let's us assume I made the search sheet so the description is in one cell.
    Break up the description into individual strings.
    Search for the first string for every match in the database.
    Search for the second string for a match in all the previous matches.
    Continue this process until you finish all the strings.
    If there was a single complete match, paste the ID# in the search sheet next to the description.
    If there was more then one complete match, paste each match ID#, as well as highlight that cell yellow.
    If there were partial matches, paste the ID#s and highlight orange. (this step I may get rid of.)
    If there were no matches, leave the ID# cell blank, and highlight red.

    This would continue until you reached the end of the search terms.

    Any advice appreciated.
    Thanks.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Matching IDs to a Database

    You may get a better response if you attach a sample file along with the description.

    I'm not quite sure of the requirement, so I am not quite sure to the solution. On the one hand, it sounds like what you need to do is create what I call a Composite Key. A composite key is simply a concatenation of elements that makes a record unique. For example [ Size ] & ":" & [ Color ] & ":" [ Number ] & ":" & [ Type ] and do your matches against that.

    On the other hand, it sounds like what you want is cascading drop-down lists. This article will get you started: http://www.utteraccess.com/wiki/Casc...ists_%28VBA%29.

    Or maybe you need a combination of both.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    12-30-2013
    Location
    Elgin
    MS-Off Ver
    Excel 2013
    Posts
    52

    Re: Matching IDs to a Database

    Hmm, reading over the cascading drop-down lists, it sounds like it's kind of like a funnel? Things need to be entered in that order or else they wont work.

    Uploading my two excel sheets. One thing I may not have mentioned - The database might have extra descriptions, and the search sheet might be more bare descriptions. So for example, the database contains a "speed" in it, where as the search sheet doesn't have that.

    I feel like I could write this code in C++, but I don't know how to incorporate C++ and excel... yet
    Attached Files Attached Files
    Last edited by Jveto; 05-26-2017 at 02:38 PM.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Matching IDs to a Database

    Now that you mention it, there is a thing called Slicers which do filter based on what is selected in other slicers.

    In my case, I work with wireless devices. An Manufacturer has multiple models and these models can be divided out by operating system. So If I select LG in the Manufacturer slicer, I get only LG models available in the Model slicer. If I then select Android as an O/S, I get only LG Android models in the Model slicer. If I then deselect LG to all Manufacturers, I get all Android models regardless of who makes them. The selection constricts the other data but unlike the cascading list, the order of the selection is irrelevant.

    Does this sound like what you are looking for? Slicers work with Excel Tables and Pivot Tables. In fact, with the pivot tables, they can be used to set the filters on multiple tables at once (provided that they are all built from the same data source). Also they look pretty cool.

  5. #5
    Registered User
    Join Date
    12-30-2013
    Location
    Elgin
    MS-Off Ver
    Excel 2013
    Posts
    52

    Re: Matching IDs to a Database

    That sounds like it could work for my application.

    Would it still be ok if search terms have different amount of terms in them? So say they can range from 1 value to 6.

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Matching IDs to a Database

    It will probably work. I could do more than speculate if you can provide a sample workbook so I can see how your data is organized. Change names or numbers to make the data non-sensitive.

+ 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. Matching new data with existing database
    By lucasar in forum Excel General
    Replies: 1
    Last Post: 09-06-2016, 11:39 AM
  2. Replies: 7
    Last Post: 05-15-2014, 08:56 AM
  3. Fetch data from database matching two conditions
    By Krishnab4u in forum Excel General
    Replies: 1
    Last Post: 04-03-2014, 07:18 AM
  4. [HELP] - How To Matching Worksheet With Database ??
    By hedhot in forum Excel General
    Replies: 7
    Last Post: 11-01-2013, 11:52 PM
  5. Replies: 1
    Last Post: 07-28-2011, 07:00 AM
  6. Matching patient personal data to that already stored in a database
    By helenjwheeler in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-18-2009, 02:00 PM
  7. Help matching fields in a database
    By simjambra in forum Excel General
    Replies: 2
    Last Post: 03-13-2009, 12:28 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