+ Reply to Thread
Results 1 to 15 of 15

Concatenate columns

Hybrid View

jschiefer Concatenate columns 10-22-2009, 03:56 PM
NoraJohnson Re: How to concatenate... 10-22-2009, 04:01 PM
jschiefer Re: Concatenate columns 10-23-2009, 03:19 AM
DonkeyOte Re: Concatenate columns 10-23-2009, 03:28 AM
JBeaucaire Re: Concatenate columns 10-23-2009, 03:42 AM
jschiefer Re: Concatenate columns 10-23-2009, 08:16 AM
hdmundt Re: Concatenate columns 12-01-2009, 02:30 PM
zbor Re: Concatenate columns 10-23-2009, 03:50 AM
JBeaucaire Re: Concatenate columns 10-23-2009, 11:42 AM
NukedWhale Re: Concatenate columns 10-23-2009, 12:30 PM
JBeaucaire Re: Concatenate columns 10-23-2009, 12:41 PM
JBeaucaire Re: Concatenate columns 12-01-2009, 04:41 PM
hdmundt Re: Concatenate columns 12-02-2009, 10:25 AM
JBeaucaire Re: Concatenate columns 12-02-2009, 03:25 PM
rsheer Re: Concatenate Macro 2 part... 06-28-2010, 10:12 PM
  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Concatenate columns

    If I understand what you're trying to do...create a new column that is the consolidation of all the other columns into one column in the next empty column...I would use a macro for this.

    Sub ConcatColumns()
    'JBeaucaire  (10/23/2009)
    Dim LC As Long, LR As Long, i As Long
    Application.ScreenUpdating = False
    LC = Cells(1, Columns.Count).End(xlToLeft).Column + 1
    
        For i = 1 To LC - 1
            LR = Cells(Rows.Count, i).End(xlUp).Row
            Range(Cells(1, i), Cells(LR, i)).Copy Cells(Rows.Count, LC).End(xlUp).Offset(1, 0)
        Next i
    
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    End Sub
    ===========
    How to use the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  2. #2
    Registered User
    Join Date
    10-22-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Concatenate columns

    Quote Originally Posted by JBeaucaire View Post
    If I understand what you're trying to do...create a new column that is the consolidation of all the other columns into one column in the next empty column...I would use a macro for this.

    Sub ConcatColumns()
    'JBeaucaire  (10/23/2009)
    Dim LC As Long, LR As Long, i As Long
    Application.ScreenUpdating = False
    LC = Cells(1, Columns.Count).End(xlToLeft).Column + 1
    
        For i = 1 To LC - 1
            LR = Cells(Rows.Count, i).End(xlUp).Row
            Range(Cells(1, i), Cells(LR, i)).Copy Cells(Rows.Count, LC).End(xlUp).Offset(1, 0)
        Next i
    
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    End Sub
    ===========
    How to use the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    Thank you, you saved me!

  3. #3
    Registered User
    Join Date
    07-19-2007
    Posts
    8

    Re: Concatenate columns

    Quote Originally Posted by JBeaucaire View Post
    If I understand what you're trying to do...create a new column that is the consolidation of all the other columns into one column in the next empty column...I would use a macro for this.

    Sub ConcatColumns()
    'JBeaucaire  (10/23/2009)
    Dim LC As Long, LR As Long, i As Long
    Application.ScreenUpdating = False
    LC = Cells(1, Columns.Count).End(xlToLeft).Column + 1
    
        For i = 1 To LC - 1
            LR = Cells(Rows.Count, i).End(xlUp).Row
            Range(Cells(1, i), Cells(LR, i)).Copy Cells(Rows.Count, LC).End(xlUp).Offset(1, 0)
        Next i
    
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    End Sub


    JBeaucaire,

    I think this is a module that should work for me, but I've followed your instructions without success. I have no real knowledge of VBS, so don't get too technical with a reply if you choose to reply. (I consulted this forum a few years ago for this same situation, i.e., a need to concatenate multiple columns/rows with the resulting strings displaying in a new column. The results were exactly what I wanted.)
    Was I to edit your code in some way before copying to the module? ('Something "understood" to VBA-cognicent folks, but not so for those like me)?
    I made sure that my "Macro Security" setting was on Medium/Low.
    My worksheet just sits there and doesn't do a thing. My worksheet is 9 columns by 60,000 rows.
    Many thanks for any suggestions you care to throw my way.

+ 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