+ Reply to Thread
Results 1 to 10 of 10

Copying contents of several cells into single cell

  1. #1
    Registered User
    Join Date
    08-10-2011
    Location
    Frankfurt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Copying contents of several cells into single cell

    Hi,

    I have to collect contents of several cells in a row into a single cell in the same row. And I have to do it for thousands of rows, which is obviosly pretty a mundane job to do. Therefore I wanted to do it through some macros.
    While copying a content of a cell, the header of the corresponding cell's column should be added before the content of the cell. You can see it below in cell D7. Some of the cells are empty and they should be skipped.
    I have to collect the contents of columns from E to J into column D.
    I would be very grateful if someone could help me out with this. Many thanks!
    Nick
    Attached Images Attached Images
    Last edited by Nickjon; 08-11-2011 at 01:46 AM.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Copying contents of several cells into single cell

    I would just use a formula like this starting at D7 and filling down:
    Please Login or Register  to view this content.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Copying contents of several cells into single cell

    For future reference, it would be much easier to work with if you'd post your actual workbook. If there are additional columns you need to check, just add them to the formula. I'd have done it for you, but I have no idea how far over you need to examine since all I got was a screenshot...

    Regards,
    Tom

  4. #4
    Registered User
    Join Date
    08-10-2011
    Location
    Frankfurt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying contents of several cells into single cell

    Hi Tom,

    Thank you very much for your reply! Indeed, I have thousands of rows of such kind of data. Even stretching out the formula, that you have kindly provided, itself would require some work.

    This time I am attaching one of the workbooks that I have. If you could help me out with writing a macros for this, I would be able to apply the macros to other workbooks. Thanks a million!

    Nick
    Attached Files Attached Files

  5. #5
    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: Copying contents of several cells into single cell

    Try this in D4
    Please Login or Register  to view this content.
    Drag/Fill Down
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Registered User
    Join Date
    08-10-2011
    Location
    Frankfurt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying contents of several cells into single cell

    Thanks, Marcol!

    I may not be so much knowledgeable about writing macros codes, but unfortunately I couldn't make use of the code you sent. I copy&paste what I did:

    Sub Macro1 (3)


    =TRIM(IF(E4<>"",$E$3&E4,"")&IF(F4<>""," "&$F$3&F4,"")&IF(G4<>""," "&$G$3&G4,"")&IF(H4<>""," "&$H$3&H4,"")&IF(I4<>""," "&$I$3&I4,"")&IF(J4<>""," "&$J$3&J4,""))

    End Sub

    I got a compile error after I had run the macros.

  7. #7
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Copying contents of several cells into single cell

    Done. See attached.
    Attached Files Attached Files

  8. #8
    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: Copying contents of several cells into single cell

    Re Post #5

    It's a worksheet formula, read the post, it goes in D4 in the worksheet.
    then use the Fill Handle to drag it down to the end of your data.

    However, seems you want a macro try this in a standard module
    Please Login or Register  to view this content.

    Hope this helps.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-10-2011
    Location
    Frankfurt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying contents of several cells into single cell

    WOW, that worked brilliant! Thank you very very much for your kind help!!!

  10. #10
    Registered User
    Join Date
    08-10-2011
    Location
    Frankfurt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying contents of several cells into single cell

    Thank you so much for your help! The code was flawless!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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