+ Reply to Thread
Results 1 to 2 of 2

Searching for values within a string across a range of cells

  1. #1
    Registered User
    Join Date
    11-22-2010
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    1

    Searching for values within a string across a range of cells

    Hello,
    I am new to VBA and I have been having a heck of a time figuring out this problem:
    I have information from two databases that need a way to correspond to each other.
    The info from each database is listed on its own sheet:

    On Sheet1:
    Column A: List of Project Numbers from Database 1 (correspond in no way to the Project Numbers from Database 2).
    Column B: List of corresponding Investigators in charge of the Projects (each Investigator has multiple projects).
    Column C: List of corresponding Project Titles.

    On Sheet2:
    Column A: List of Project Numbers from Database 2 (correspond in no way to the Project Numbers from Database 1).
    Column B: List of corresponding Investigators for the Projects (each Investigator has multiple projects).
    Column C: List of corresponding Project Titles.
    Column D: Strings extracted from middle of Titles listed in Column C.

    I am planning on merging these to databases together, in order to do this I will have to match the Project Numbers on Sheet2 to the Projects listed on Sheet1.

    Ordinarily, when I do something like this I would just use a vlookup between the two sets of Project Titles in order to determine the appropriate Project Numbers. However, because these two Databases were created somewhat independently, most of the project titles are slightly different (someone has added text to either the end or beginning of a given Project Title). What I have done is extracted a string in the middle of the Title listed in Sheet2, Column C and placed it in Column D of the same sheet.

    So, what I have been trying to do is write a VBA function that will use the instr function that will search for the instance of the string listed in Sheet2, Column D within Sheet1, Column C by looping through its entire range. When a match is found it will then make sure that the corresponding Investigator listed in Sheet2, Column B for the Project matches the Investigator listed for the Project in Sheet1, Column B. If both these conditions are true then the appropriate Project Number listed on Sheet2, Column A will be placed in Column D of Sheet1.

    Sorry, that was quite a mouthful, this is my first time posting a question so please let me know if you have any questions about my post. Thanks so for in advance for your help!

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Searching for values within a string across a range of cells

    Hi

    Build us an example file, and give some expected results from the data you supply.

    rylo

+ 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