+ Reply to Thread
Results 1 to 7 of 7

Concatenate Cells Based on a Condition in Next Row

  1. #1
    Registered User
    Join Date
    11-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Concatenate Cells Based on a Condition in Next Row

    Hi there. I am a VBA novice and am looking to learn how to complete this action. I have a table (on a separate sheet) where i need to concatenate cells based on a condition in another cell. I need to pull all of the names that meet a criteria in another row and concatenate them with a semi-colon between them:

    Name Approver
    Mark Tom
    Alex Jenna
    Jessie Tom

    In this example, I would have the macro reference a cell with "Tom" in it and then I would need to build a concatenation of all the names that are of that approver.

    The end result when referencing a cell with "Tom" in it would be

    "Mark;Jessie"

    Let me know where I can begin.

    Thanks!



    MODERATOR'S NOTE: Please select the correct forum for each question. I've moved this question to the VBA/Programming forum for you.
    Last edited by JBeaucaire; 11-02-2012 at 07:42 PM. Reason: moved to correct forum

  2. #2
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Concatenate Cells Based on a Condition in Next Row

    You can try this code
    Please Login or Register  to view this content.
    I assumed the values are in column A and B

  3. #3
    Registered User
    Join Date
    11-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Concatenate Cells Based on a Condition in Next Row

    Thank very much! That is a great start. I have a couple simple questions for you.

    -How do I change it from column "B" to column "E" to search for a match?
    -How do i change it to reference a cell on another sheet? (This macro will run on "Sheet1" and for information on "sheet2" and ouput in a cell on "sheet1")
    -How do i change the "TOM" match to reference another cell where the search query is located? (again the cell is on "sheet1" for data on "sheet2")

    I obviously need to learn the basics. Anyone know a good book or place to start?

  4. #4
    Registered User
    Join Date
    11-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Concatenate Cells Based on a Condition in Next Row

    I guess anyone could help me with these fixes if they understand the code sidhus wrote.

    Thanks

  5. #5
    Valued Forum Contributor
    Join Date
    08-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    573

    Re: Concatenate Cells Based on a Condition in Next Row

    Modified the code. Assuming Name column is in sheet2-A column, Approver is in Sheet2-E Column.
    Search criteria (TOM) is in sheet1-A1, Output is written in Sheet1-B1
    Please Login or Register  to view this content.
    Quote Originally Posted by brendanec View Post
    Thank very much! That is a great start. I have a couple simple questions for you.

    -How do I change it from column "B" to column "E" to search for a match?
    -How do i change it to reference a cell on another sheet? (This macro will run on "Sheet1" and for information on "sheet2" and ouput in a cell on "sheet1")
    -How do i change the "TOM" match to reference another cell where the search query is located? (again the cell is on "sheet1" for data on "sheet2")

    I obviously need to learn the basics. Anyone know a good book or place to start?

  6. #6
    Registered User
    Join Date
    11-02-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Concatenate Cells Based on a Condition in Next Row

    Thank you so much for your help. This works perfectly and has taught me a lot.

    1 final request - is it possible to remove the last ";" from the output?

    from:
    "tom;alex;mark;steve;"

    to:
    "tom;alex;mark;steve"

    Thanks!

  7. #7
    Registered User
    Join Date
    07-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007/2010
    Posts
    86

    Re: Concatenate Cells Based on a Condition in Next Row

    Modified the last row
    Please Login or Register  to view this content.
    Boon

+ 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