+ Reply to Thread
Results 1 to 8 of 8

Selecting Multiple columns based on headers and copying to seaperate sheet

  1. #1
    Registered User
    Join Date
    12-11-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2007
    Posts
    10

    Selecting Multiple columns based on headers and copying to seaperate sheet

    Guys,

    I need a bit of help with this - I have a report that is run weekly and the information I need from it is under headings in Row 1, these are not always in the same column so I can't simply use column A etc.

    There are approx 40 columns and I need to pull 16 of them out into a new worksheet in a specific order - for example Column Z might have header "Age" and I need that in Column A in the new worksheet.

    I have been trying to approach this for an array perspective but it's not working at all for me so any advice would be greatly appreciated
    Last edited by jonto81; 12-12-2010 at 06:29 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    please post sample workbook with original data and result you'd like to obtain

  3. #3
    Registered User
    Join Date
    12-11-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    Sorry - I have attached a quick mock up of what I want to achive - RAW DATA (there are a lot more headings but this is just an example) is what I start with and MIS is what I want the Macro to create from this data (in the order they are in with the 2 empty columns as well)
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    see attachment, run macro "MoveColumns"
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-11-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    Many thanks Watersev, does exactly what I need - if you get a chance can you post an explination of the code so that I can amend or adapt in the future

    Thanks

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    see attachment, explanation is in code as remarks. I have amended the code a bit in order for it to deal with error (when there is no such header in original table).
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-11-2010
    Location
    Belfast
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    Exclent - Thank you very much

  8. #8
    Registered User
    Join Date
    12-03-2013
    Location
    Athens
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Selecting Multiple columns based on headers and copying to seaperate sheet

    Dear watersev,

    i know your post is quite old, but if you are out there, I am using your VB code (which is excellent btw, thank you). However, sometimes not all columns exist in my original data, so I get an error which stops the sub. Is there a way to keep it running and searching only for the column headers available in the original data?

    thank you

+ 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