Results 1 to 22 of 22

Copy columns from sheet 1 to sheet 2 using column heading as criteria using VBA

Threaded View

  1. #11
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,889

    Re: Copy columns from sheet 1 to sheet 2 using column heading as criteria using VBA

    I see the really good guys have arrived
    apo, I made a tiny change to your code. I also timed it, something like 10^-8 seconds, fast enough he he...

    Option Explicit
    Sub Click()
        Dim x
        With [A1].CurrentRegion
            x = .Offset(1).Resize(.Rows.Count - 1, .Columns.Count + 1).Value
            Sheets("Sheet1").Cells(2, 1).Resize(UBound(x), 12) = Application.Index(x, Evaluate("row(1:" & UBound(x) + 1 & ")"), Array(1, 6, 4, 13, 35, 36, 37, 19, 28, 15, 2, 3))
        End With
    End Sub

    Good looking piece of code there Marc L, very compact. However it takes about 0.6 seconds on my pc, about ten times slower than my code. Also I think you missed the empty column.
    Last edited by Jacc; 07-21-2015 at 02:02 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Columns to another sheet based on column heading
    By jhall488 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-05-2014, 03:46 PM
  2. [SOLVED] Auto copy contents from sheets 2 and 3 to sheet 1 if column heading contains set words
    By Thomas Andrews in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 06-09-2014, 11:59 AM
  3. how to copy columns of another sheet with the column data of current sheet
    By amethystfeb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2014, 11:28 PM
  4. [SOLVED] COUNTIF with multiple criteria on several columns (different column heading)
    By rose4emi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-20-2012, 06:41 AM
  5. [SOLVED] Search for heading in data sheet and copy range to corresponding sheet in master workbook
    By sans in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-07-2012, 10:02 AM
  6. Macro to filter based on column heading then copy and paste to new sheet
    By macattackr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2012, 05:14 PM
  7. Search for column heading and copy column onto another sheet
    By chrismann85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2008, 05:53 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