+ Reply to Thread
Results 1 to 4 of 4

Copying and moving multiple columns around

Hybrid View

  1. #1
    Registered User
    Join Date
    12-09-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    21

    Copying and moving multiple columns around

    Hey all,

    I've got data in columns C,F,I,K,L,O and P and can't for the life of me figure out how to copy them into a new workbook, so they're then all side by side in the new book.

    I thought this would've been really easy to find the answer to, but seems not to be the case, alas. Column K then needs to be on the right of column L and O on the right of P.

    I can't attach the sheet that it actually needs doing on as the data is confidential, but I've mocked up a very quick dummy sheet for example.

    Thanks in advance!

    This is what I have at current, as well

    
    Sub CreateReport_step1()
    
        Dim nDate$
        Dim FileName_IMM$
        Dim FileName_BATML$
        
        nDate = Format(Now, "yyyymmdd")
        FileName_IMM = "Master Report " & nDate & ".xls"
        FileName_ML = "Master List " & nDate & ".xls"
    
        Windows("MAster Report - " & nDate & ".xls").Activate
        'Selects the daily report
        Sheets(1).Select
        'Selects the relevant Sheet
        Range("C" & "F" & "I" & "K" & "L" & "O" & "P").Copy
        'Selects the columns with the data we need for the Master List
            
        Workbooks.Add
        Range("A1").Select
        ActiveCell.PasteSpecial (xlPasteColumnWidths)
        Selection.Paste
            
    End Sub
    Attached Files Attached Files
    Last edited by Leith Ross; 12-13-2010 at 02:29 PM.

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

    Re: Copying and moving multiple columns around

    Hi,

    Sub test()
    Union([c:c], [f:f], [i:i], [l:l], [k:k], [p:p],[o:o]).Copy Sheets(3).[a1]
    End Sub
    Last edited by watersev; 12-13-2010 at 02:40 PM.

  3. #3
    Registered User
    Join Date
    12-09-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copying and moving multiple columns around

    Watersev,

    I try running it and I get an error message saying 'Object doesn't support this property or method'.

    Any ideas?

    Thanks.

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

    Re: Copying and moving multiple columns around

    activate sheet "Before" and run macro "test"
    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)

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