Posts by DonLennon


    Hopefully I can explain this properly..

    I have two tables: NAME & DETAILS

    NAME just contains a list of names e.g.


    then DETAILS contains a field which may contain these names, although this could be anywhere in the field, and some of the data won't contain any of the names from the original table e.g.

    Bob Johnson
    Mark Dave Roberts
    Philip [Don't want]
    Chris [Don't want]

    What I want to do is produce a select query which will pull back all of the entries from the DETAILS table where it contains one of the names (i.e the first four entries in the above example.

    I'm sure ths must be possible somehow but I can't for the life of me think of a way to do it.

    Any help would be much appreciated.


    Hi All,

    I am trying to create an Excel function that can query an oracle database, using the data in a cell in Excel. For example:

    I have an oracle database with a table CustDetails containing all customer names and their addresses.

    I then have an excel spreadsheet containing various customer names in column B. I want to be able to enter in column C "=GetPostcode("B2"), and then this will pull back the information from the Oracle database using SQL such as

    Select PostCode From CustDetails Where CustomerName = [the data fed to function]

    Is anyone able to point me in the direction of some code to help with this? My general VBA skills are pretty good, but i just have no knowledge of ADO, and not much SQL.

    Any help would be much appreciated.



    Re: VBA code for "contains"

    Brilliant set of answers guys - thanks a lot!

    I'm getting quite addicted to this VBA stuff at work. Give it a few more months, and my whole job will be a case of pushing one button!


    I'm hoping this is a pretty simple question. I am basically looking for some code that can look if a cell contains a certain string.

    To date I have only been able to look for exact strings e.g.
    If UserName = "Bob Jones"....

    What I am looking for is:
    If UserName contains "Bob" ...

    Thanks for your help