+ Reply to Thread
Results 1 to 7 of 7

Concatenate function

  1. #1
    Forum Contributor
    Join Date
    05-24-2010
    Location
    London England
    MS-Off Ver
    Excel 2003
    Posts
    345

    Smile Concatenate function

    Hi there,

    I'm trying to improve my quite basic excel skills and have therefore decided to join this forum.

    Not sure if anyone can help me, but today I encountered the following problem.

    I have two columns.

    Column A has a list of each shop in the business organisation. Column B has the name of the shop's competitor.

    However, if there is more than 1 competitor for that shop, the shop number is repeated underneath with the corresponding competitor name in column B.

    So it looks like this

    Shop no Competitor name
    1 A
    1 B
    2 A
    2 B
    2 C
    3 B

    Etc etc for thousand of shops.

    What I need in a seperate column is the shop no and in the next column the names of all the competitors for that shop, so look like this

    Shop no Competitor names
    1 A B
    2 A B C
    3 B

    I had a play with this but just can't get it to work properly.

    Any help on this would be greatly appreciated.

    Cheers
    Last edited by floricita; 05-24-2010 at 09:39 AM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Help with Concatenate function

    Try this as a VBa option

    Please Login or Register  to view this content.

    I have attached a small demo workbook

    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    05-24-2010
    Location
    London England
    MS-Off Ver
    Excel 2003
    Posts
    345

    Re: Help with Concatenate function

    Hi there and thanks for the response.

    I know it may sound silly, but with macros/vba I have very basic knowledge and normally just press the record mode to record the VBA.

    I've never just written VBA by itself and am not sure how exactly to record it in written form and then how to apply it to the work sheet?


    Thank you.

  4. #4
    Forum Contributor
    Join Date
    05-24-2010
    Location
    London England
    MS-Off Ver
    Excel 2003
    Posts
    345

    Re: Help with Concatenate function

    Ok, I kind of cheated and stepped into one and cut and pasted this code, but when I ran it nothing happenned, and no errors either???

  5. #5
    Forum Contributor
    Join Date
    05-24-2010
    Location
    London England
    MS-Off Ver
    Excel 2003
    Posts
    345

    Re: Help with Concatenate function

    Oh my god, sorry I am very much a novice at this, I had it on break mode, now I put it on normal mode and ran it and it works.

    Thank you so much, I am so happy.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Help with Concatenate function

    Go to the VBA Editor (ALT F11) and INSERT>Module. Then paste the code in that window. Did that help?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Help with Concatenate function

    The proceduire is as follows

    1/. Open the VBa Editor
    Tools > Macro > Visual Basic Editor (or Press Alt+f11)

    2/. In the VBa Editor
    Insert > Module

    3/. In the new module pane that appeared
    Paste ALL of the code from post #2

    4/. In Excel
    Tools > Macro > Macros....
    Select the desired macro, in this case, "ConcatenateNames"
    Press Run.

    Alternatively
    1/. Open the demo workbook "ConcatenateNames.xls"

    2/. Open the VBa Editor as above

    3/. If the module is not already showing
    In the Project pane (Ctrl+R) double click on Module 1

    4/. File > Export File....
    Save the module to your desired location

    5/. With your workbook
    In the VBa Editor
    File > Import File....
    Select the saved file (it will be named Module1.bas unless you gave it some other name)
    Press Open


    You may have to adjust the column references to suit your worksheet.

    If you run into any problems, post a sample Workbook and I will adjust the code to suit.

    Cheers.

    P.S.
    I missed all of the intervening posts, none of them were showing when I posted this!!! ????
    Last edited by Marcol; 05-24-2010 at 10:06 AM.

+ 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