+ Reply to Thread
Results 1 to 7 of 7

Creating a string concatenating elements of column separated by specific values

  1. #1
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Creating a string concatenating elements of column separated by specific values

    Hello

    I'm trying to create VBA code to do this: I have three columns, one is the identifier of the person the other the date of the task and the other the task.
    For each person I need to create a string as shown in bold in the example. The string always starts with -3 and ends with -2
    All the tasks that are performed by a person the same day are separated by -1 values. Therefore every string ends always with -1-2
    I should attach the excel but I'm not able to attach excel files

    Please Login or Register  to view this content.

    It doesn't matter if in the result there are blank rows inbetween each different person as in the example. The identifiers are in column A, the date in column B, the Task (is a number) and is in column C, column D is just to show the tasks in one day but I dont have to create it, it is just to show the example, I must create the column E which is in Bold.
    I need to traverse the A column keeping track of the changes in B column and adding to the string and when it changes the id I need to create a new string but I'm new to VBA and doing a mess with this

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Creating a string concatenating elements of column separated by specific values

    Enter this formula in column D and fill down

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enter this formula in column E and fill down

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I will now build these into a macro for you.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 02-13-2017 at 05:51 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Re: Creating a string concatenating elements of column separated by specific values

    Thanks so much mehmitcik, I think that trying to solve it with formulas is better than VBA code because I have a lot of rows to process and I might get memory error with VBA
    But when executed your macro I only got one line for example, when running the macro for all this lines I only get one day activity..

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Creating a string concatenating elements of column separated by specific values

    Apologies

    In trying to tidy up the formula I messed it up.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Creating a string concatenating elements of column separated by specific values

    This solution requires a user defined function called CONCATALL and a helper column.

    The user defined code is :
    http://www.excelforum.com/tips-and-t...ml#post3096647

    Please Login or Register  to view this content.
    Array enter this formula in D2 and fill down. It is the helper column. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The final formula is array entered in E2 and filled down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  6. #6
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Re: Creating a string concatenating elements of column separated by specific values

    Thanks a lot!!!!!!!!!!!!!!!!!!! Great!!!!!!!!!!!!!!!!!

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Creating a string concatenating elements of column separated by specific values

    You're welcome. Glad to help, and thanks for the rep.

    tigeravatar did the 'heavy lifting' here. Follow that link I posted. Please consider giving rep to him (her?). Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Creating text string based on column titles and values below
    By h2whoa in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-19-2016, 06:17 AM
  2. [SOLVED] Concatenating part of string in two columns into a new column
    By Karl Gustaf Karsten in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2015, 04:57 PM
  3. Help Creating a comma separated list based on a specific column
    By zach.shupp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2014, 09:44 PM
  4. [SOLVED] Separated first string which is separated by dash (-) or underscore (_) or space ( )
    By nur2544 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-03-2014, 10:32 AM
  5. [SOLVED] Need to search for a specific string in Column A and delete values within the same row
    By hgeo24 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-27-2014, 04:56 PM
  6. Runtime Error 1004 when concatenating numeric values into string
    By spokok in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2013, 04:33 PM
  7. creating a public constant by concatenating string......gives compile error
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2011, 07:23 AM

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