Results 1 to 9 of 9

Copying specific columns

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,090

    Copying specific columns

    I have a routine that filters a spreadsheet containing 27 columns of data. After the filter I copy the visible rows to paste into another spreadsheet. I really don't need the whole row, just a few specific columns of data. How do I select just those ranges to copy/paste? My code is below, with the "Copy and paste only the filtered data" part being what I think needs changing. Any help would be appreciated.



     'Restrain the filter to cells from A1 to the last entry in column X
            With DstWkb.Worksheets("APRData")
                Set rng = .Range("A1:X1")
                Set RngEnd = .Cells(Rows.Count, rng.Column).End(xlUp)
                Set rng = IIf(RngEnd.Row < rng.Row, rng, .Range(rng, RngEnd))
            End With
              
            'Filter the data using column M
              rng.EntireRow.Autofilter Field:=13, Criteria1:=("0")
                           
              'Trap the error if there were no matches
              On Error Resume Next
              
              'See whether there's data or not
            Set rng2 = Range("A2:X" & Rows.Count).SpecialCells(xlCellTypeFormulas)
              If rng2 Is Nothing Then
                DstWkb.Worksheets("Report").Range("A65536").End(xlUp).Offset(1, 0) = "Congratulations!  You have no Zero FTEs!"
            Else
                            
               'Copy and paste only the filtered data
               Range("J1").Activate
               'Set rng = IIf(RngEnd.Row < rng.Row, rng, .Range(rng, RngEnd))
                rng.SpecialCells(xlCellTypeVisible).copy _
                    Destination:=DstWkb.Worksheets("Report").Range("A65536").End(xlUp).Offset(1, 0)
            End If
    Last edited by jomili; 05-20-2010 at 10:08 AM.

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