+ Reply to Thread
Results 1 to 20 of 20

Filter, copy specific columns, and paste to another sheet.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Filter, copy specific columns, and paste to another sheet.

    Good morning,
    Yeah it is 1:33 am where I am.
    I'd like to filter a column and paste only 2 columns to another sheet in the first available row.
    I found a code that was posted by Tom Ogilvy and made a few adjustments:
    Sub Test1()
    Set rng = Sheets("Sheet1").AutoFilter.Range
    If rng.Columns(1).SpecialCells(xlVisible).Count > 1 Then
    rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy _
    Destination:=Sheets("Sheet2").Range("A2")
    Else
    MsgBox "No visible data"
    End If
    End Sub
    I can't seem to adjust it to copy 2 columns.
    I've attached a file.
    Can anyone help?
    Regards,
    Xrull
    Attached Files Attached Files
    Last edited by Xrull; 09-29-2009 at 06:34 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Filter, copy specific columns, and paste to another sheet.

    If the 2 columns are contiguous try altering the Resize from

    rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy
    to

    rng.Offset(1, 0).Resize(rng.Rows.Count - 1,2).Copy
    EDIT: just looked at the attachment and note the above will not always be appropriate (as is)

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Filter, copy specific columns, and paste to another sheet.

    Questions...

    Are you only ever copying 2 columns or is the intention such that you will modify headers on Sheet2 row 1 and you intend to copy data from Sheet1 to match the headers listed on Sheet2 (B1 onwards) ?

  4. #4
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Filter, copy specific columns, and paste to another sheet.

    DonkeyOte,
    My actual spreadsheet has 54 columns. I want to filter by column 54 (BB) and copy only columns copy columns B, T,AD, AO:AQ.
    Thanks,
    Xrull

  5. #5
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Filter, copy specific columns, and paste to another sheet.

    Bump I'm still working on it.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Filter, copy specific columns, and paste to another sheet.

    Slipped under the radar... sorry... perhaps:

    Public Sub Standard()
    Dim wsSource As Worksheet, wsOutput As Worksheet, rngData As Range
    Set wsSource = Sheets("Sheet2")
    Set wsOutput = Sheets("Sheet1")
    With wsSource
        Set rngData = .AutoFilter.Range
        If rngData.Columns(54).SpecialCells(xlCellTypeVisible).Count > 1 Then
            Intersect(rngData.Offset(1).Resize(rngData.Rows.Count - 1), .Range("B:B,T:T,AD:AD,AO:AQ")).Copy wsOutput.Cells(Rows.Count, "A").End(xlUp).Offset(1)
        Else
            MsgBox "No Visible Data"
        End If
    End With
    Set rngData = Nothing
    Set wsOutput = Nothing
    Set wsSource = Nothing
    End Sub
    Alter sheets & ranges to suit requirements.

+ 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