+ Reply to Thread
Results 1 to 11 of 11

Copy columns based on header (Without header)

  1. #1
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Copy columns based on header (Without header)

    Hi guys,

    I want to copy some columns to another sheet based on the header. But without copying the Headers itself.
    I've attached the file in which I want to do it.

    So the columns from sheet1 (A2:M2) downwards, have to be copied to the sheet INPUT range (A6:M6)...
    But on sheet1, the order of the columns can be different, or there can be less columns (based on a dropdown list).

    Can this be done?

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy columns based on header (Without header)

    Does this help?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Re: Copy columns based on header (Without header)

    Well, this will copy all the columns, but if the column order in the 2 sheets is different, then it will not work correctly I suppose.
    Any solutions for that problem?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy columns based on header (Without header)

    Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Re: Copy columns based on header (Without header)

    Works like a charm!
    Thanks for the solution John.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy columns based on header (Without header)

    You're welcome. Glad to help out and thanks for the feedback.

  7. #7
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Re: Copy columns based on header (Without header)

    Oh, forgot 1 thing. I want to preserve the format on the sheet INPUT. Can I use a pastevalues with the .copy method?

  8. #8
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Re: Copy columns based on header (Without header)

    found it. changed the copy to:

    Cells(i, z).Copy
    Sheets("INPUT").Cells(Rows.Count, y.Column).End(3)(2).Pastespecial xlPasteValues
    Last edited by Michael_BU; 10-13-2014 at 09:05 AM.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy columns based on header (Without header)

    Or:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-13-2014
    MS-Off Ver
    Excel 2010 & 2019
    Posts
    21

    Re: Copy columns based on header (Without header)

    Thanks

    One last question. Can this macro be reformed in a vba formula, so that I can enter the formula on the INPUT-tab. Which will then give the value of the corresponding column of the sheet1-tab?
    Or is there an excel formula that can do this?

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy columns based on header (Without header)

    You may want to try VLOOK-UP. Click on your help screen and see it that is what you need.

+ 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. Copy data from header to header in consolidation sheet
    By Ignesh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-12-2013, 04:10 AM
  2. Need to copy header row in group to all rows below header; stop if blank and repeate
    By jmcaleer10 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2013, 11:09 AM
  3. Replies: 2
    Last Post: 10-13-2012, 03:30 AM
  4. Automatically copy row header to column header...
    By Soons in forum Excel General
    Replies: 4
    Last Post: 10-16-2008, 11:38 AM

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