+ Reply to Thread
Results 1 to 11 of 11

Copying and combining Excel columns - Multiple Worksheets

  1. #1
    Registered User
    Join Date
    02-24-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    5

    Post Copying and combining Excel columns - Multiple Worksheets

    I have a workbook with multiple worksheets that have similar data. I need to combine column C from selected (or all) worksheets into a new worksheet. I'm trying to create a key to be used in a separate SQL query. This is a monthly report so I need some automation.

    Thanks!
    Attached Files Attached Files
    Last edited by Bewildered101; 02-27-2012 at 05:51 PM.

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Copying and combining Excel columns - Multiple Worksheets

    Can you upload a sample workbook with no sensitive data showing how the data currently is presented and how you want it to appear - So in a sample sheet show how you want the data to be appear after the macro has run. It makes it much easier to supply you an accurate answer if we can see how your workbook is constructed and if we can see an example of how the workbook is to appear after the macro has processed the data. Select Go Advanced, Manage Attachments and select the dummy workbook to upload. Make sure no sensitive/private data is in the workbook you upload. Do not upload screen dumps as no one wants to reconstruct a workbook based on an image.
    You will have a much better chance of getting an answer if you could supply a sample workbook.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    02-24-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying and combining Excel columns - Multiple Worksheets

    I have attached an example of what I'm looking for. I want to combine column C from Sheets 1,2 & 3. The result tab is what I need. My first try at getting help here... Thanks!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Copying and combining Excel columns - Multiple Worksheets

    You could use the following. If the result worksheet exists then it will just append to the current data otherwise it will create the result worksheet
    Please Login or Register  to view this content.
    See attached workbook
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-24-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying and combining Excel columns - Multiple Worksheets

    Wow! Thanks. I tried it and it works with only one exception. I have several empty workbooks and it returns the column heading into the result column. I can still use it this way, but it would look better. thanks! bravo!

  6. #6
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Copying and combining Excel columns - Multiple Worksheets

    If the workbook is empty then this code will not place the column heading.
    Please Login or Register  to view this content.
    I hope this is what you mean.
    If this solves your problem then please say so by marking your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes.
    If you still need modifications then just ask.
    Last edited by smuzoen; 02-24-2012 at 08:37 PM.

  7. #7
    Registered User
    Join Date
    02-24-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying and combining Excel columns - Multiple Worksheets

    I tried it on this test document and it still carries the column heading. Nearly perfect... If you can fix it, great. I appreciate your help.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Copying and combining Excel columns - Multiple Worksheets

    I am confused - if you run the code on a document with all blank sheets then the results sheet is still created however it will not create a column heading on the Result sheet - see attached wordbook.
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Copying and combining Excel columns - Multiple Worksheets

    Do you mean that you don't want the results tab generated if there is no data in the sheets/empty workbooks? or Just to clarify you mean with an Empty workbook you say that the heading in Column A on the report sheet still has "Combined Code Column" when you run the code? If the latter is so just make sure you are using the new code and not the old code. Try running the workbook in the last post and you will see that there is NO HEADING in the results sheet in Column A.
    I just want to be clear on what has to be fixed. Let me know

  10. #10
    Registered User
    Join Date
    02-24-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copying and combining Excel columns - Multiple Worksheets

    Sorry if I'm not explaining well enough. When you run the attached workbook I sent earlier, (Combine columns 2.XLS) Here are the results... notice that it has the column heading "Code" included in the results because of the blank sheet (that only contains column headings). So it's grabbing the column heading and putting it into the result sheet. I'm still able to use your code, but I would like it to be cleaner if possible. Thank you for your help!

    Combined Code Column
    111111
    222222
    333333
    444444
    555555
    666666
    777777
    888888
    999999
    Code
    131313
    242424
    353535
    464646
    575757
    686868
    797979
    808080
    979797

  11. #11
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: Copying and combining Excel columns - Multiple Worksheets

    Sorry for the late reply - I see the error now - it is fixed. Sorry took so long however have been busy - was a silly mistake on my behalf. The word Code will now not get copied if the sheet contains no data. Again my apologies for not getting back to you earlier.
    Please Login or Register  to view this content.
    Workbook attached.
    Attached Files Attached Files

+ 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