+ Reply to Thread
Results 1 to 6 of 6

Macro to concatenate different columns based out a list

  1. #1
    Registered User
    Join Date
    03-09-2013
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    8

    Macro to concatenate different columns based out a list

    Hi There,

    Looking for a macro to do the below. Much appreciated.

    Sheet1:
    ColA ,ColB , ColC,ColD ,ColE
    Row1: Name , Address, ID , Company, <Blanks>
    Row2: aaaaa , bbbbbbb,111 ,ccccc , <Blanks>
    Row3: ddddd , eeeeeee, 333, fffff , <Blanks>

    Sheet2:
    ColA
    Row1 Name
    Row2 ID
    Row3 Company

    Once we run the macro, the results in Sheet1 should be below.
    ColA , ColB , ColC , ColD, ColE
    Row1: Name , Address, ID, Company , Name-ID-Company
    Row2: aaaaa , bbbbbbb,111 ,ccccc ,aaaaa-111-ccccc
    Row3: ddddd , eeeeeee, 333, fffff , ddddd-333-fffff

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Macro to concatenate different columns based out a list

    I have prepared it for you
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro to concatenate different columns based out a list

    Perhaps
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    03-09-2013
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Macro to concatenate different columns based out a list

    Thanks, Yasser. Its not working. Stops at the below point.

    For I = 1 To .Cells(Rows.Count, "A").End(xlUp).Row

    Thanks

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Macro to concatenate different columns based out a list

    Can you attach your workbook. It's working for me?

  6. #6
    Registered User
    Join Date
    08-25-2015
    Location
    ESSEX, ENGLAND
    MS-Off Ver
    2007
    Posts
    3

    Post Re: Macro to concatenate different columns based out a list

    Hi there!

    I think the following macro can do the trick:

    Sub concat()
    Dim curcell As Range
    Dim i As Integer


    'This is to fill the title of the column to be created
    Cells(1, 6).Value = "Name" & "-" & "ID" & "-" & "Company"


    'This is to count the number of rows to loop through
    cntr = ActiveSheet.UsedRange.Rows.Count


    For i = 2 To cntr

    Set curcell = Cells(i, 6)

    curcell.Value = curcell.Offset(0, -4).Value & "-" & curcell.Offset(0, -2).Value & "-" & curcell.Offset(0, -1)


    Next i

    End Sub

+ 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. Replies: 11
    Last Post: 07-28-2015, 05:08 PM
  2. Macro to Hide/Unhide Columns Based on a Validation List
    By Legalhustler in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2015, 01:23 PM
  3. Replies: 2
    Last Post: 01-05-2015, 08:06 PM
  4. [SOLVED] Concatenate row data in columns B-F based on duplicate value in column A
    By wolffia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 10:03 AM
  5. need to Concatenate two columns by a macro
    By rsami in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 07:06 AM
  6. [SOLVED] Concatenate two columns VBA macro
    By longbow007 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 11:20 PM
  7. concatenate rows with columns based on conditional formatting in VBA?
    By bandit_kaine in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2010, 03:16 AM

Tags for this Thread

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