+ Reply to Thread
Results 1 to 11 of 11

Copy columns based on header (Without header)

Hybrid View

  1. #1
    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?

    Sub Michael_BU()
    Dim i As Long
    For i = 2 To Range("A" & Rows.count).End(3).Row
    Range(Cells(i, 1), Cells(i, 13)).Copy Sheets("INPUT").Range("A" & Rows.count).End(3)(2)
    Next i
    End Sub

  2. #2
    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?

  3. #3
    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:

    Sub Michael_BU()
    Dim i As Long
    Dim z As Long
    Dim x As String
    Dim y As Range
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    For i = 2 To Range("A" & Rows.count).End(3).Row
        For z = 1 To ActiveSheet.UsedRange.Columns.count
        x = Cells(1, z).Value
        Set y = Sheets("INPUT").Rows(5).Find(x, LookIn:=xlValues, lookat:=xlWhole)
        If Not y Is Nothing Then
        Cells(i, z).Copy Sheets("INPUT").Cells(Rows.count, y.Column).End(3)(2)
        End If
        Set y = Nothing
        Next z
    Next i
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    End Sub

+ 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