+ Reply to Thread
Results 1 to 7 of 7

Multiple Instances of a Name

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Multiple Instances of a Name

    I have a large dataset with a company name in Column A and a Town in Column B, e.g.

    ABC Company London
    ABC Company London
    XYX Company Swindon
    STJ Company Bristol
    STJ Company Bristol
    STJ Company Bristol
    DEF Company London
    DEF Company London
    DEF Company London

    and I need to identify every instance where the same town appears for each instance of each individual company and add in Column C incrememnt the town name, so the above should end up looking like this:

    ABC Company London London
    ABC Company London London-1
    XYX Company Swindon Swindon
    STJ Company Bristol Bristol
    STJ Company Bristol Bristol-1
    STJ Company Bristol Bristol-2
    DEF Company London London
    DEF Company London London-1
    DEF Company London London-2

    I'm thinking I need to use some sort of lookup, but because of the volume of the instances of each company I have no idea how many instance appear in the data set. How could I go about achieving this and incrementing the town names in Column C automatically for each instance?

    Many thanks

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,704

    Re: Multiple Instances of a Name

    Using MS Query, I was able to create a query in Excel using this SQL statement to get the desired results

    Please Login or Register  to view this content.
    You would have to change your path and field names to match what you have in your spreadsheet. Here is a tutorial on using MS Query

    http://www.exceluser.com/explore/msquery1_1.htm

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,114

    Re: Multiple Instances of a Name

    Maybe:

    C2: =IF(COUNTIFS($A$2:$A2,A2,$B$2:$B2,B2)-1=0,B2,B2&"-"&COUNTIFS($A$2:$A2,A2,$B$2:$B2,B2)-1) ... dragged down


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Multiple Instances of a Name

    Hi Alan and TMShucks

    I don't have Microsoft Query and really want to do this within Excel...

    TMShucks' solution works perfectly... Many thanks, that is brilliant!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,114

    Re: Multiple Instances of a Name

    You're welcome.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,114

    Re: Multiple Instances of a Name

    Thanks for the rep.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,704

    Re: Multiple Instances of a Name

    Hangman--all copies of Excel carry MS Query built in. If you read the tutorial you would know this. It is a very powerful tool that supplements Excel and should not be dismissed lightly. Good luck with your project.

    Alan

+ 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