+ Reply to Thread
Results 1 to 4 of 4

Copy & Paste Filtered Data

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-04-2011
    Location
    Phoenix, Arizona
    MS-Off Ver
    Excel 2003
    Posts
    129

    Copy & Paste Filtered Data

    Hello All,

    I am working with a spreadsheet that can have up to 60,000 lines. Every 10th line in Column "A" I need the term "Item". I have recorded a macro that allows me to filter on the term "Order Type" and that gives me every 10th line one above the other. When I manually copy and Paste "item" then it works perfectly. However, if I run the below macro then it puts the term "Item" into EVERY line that has data in it.

    How can I get this to work? I wrote a macro that looked for the term "order Type" and would input "Item" next to it, but that took a very LONG time to execute. The filter method takes just a few seconds. Any help is greatly apprecaited.

       Selection.AutoFilter
        ActiveSheet.Range("$A$1:$O$62560").AutoFilter Field:=1, Criteria1:="<>"
        Range("A11:A62551").Select
        Selection.ClearContents
        Range("A1").Select
        Selection.Copy
        Range("A11:A62551").Select
        ActiveSheet.Paste
        ActiveSheet.Range("$A$1:$O$62560").AutoFilter Field:=1

  2. #2
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Copy & Paste Filtered Data

    jkelly,

    First off you do not need to "SELECT" cells to do what you want.
    All you need to do is add the SpecialCells(xlCellTypeVisible) to your Paste destination.

    I don't have your complete code, but a snipit might look like this:
        Range("A1").AutoFilter Field:=1, Criteria1:="Order Type"
        Range("A1").Copy _
        Destination:=Range("A1:A25").SpecialCells(xlCellTypeVisible)
        ActiveSheet.ShowAllData
    Hope this helps!

  3. #3
    Forum Contributor
    Join Date
    01-04-2011
    Location
    Phoenix, Arizona
    MS-Off Ver
    Excel 2003
    Posts
    129

    Re: Copy & Paste Filtered Data

    Chance2,

    Sorry, I can't get it to work. I think it is the right track, but it doesn't actually filter on "Order Type". This starts in Column "B1". Here is the code

        Range("B1").AutoFilter Field:=1, Criteria1:="Order Type"
        Range("A1").Copy _
        Destination:=Range("A1:A65000").SpecialCells(xlCellTypeVisible)
        ActiveSheet.ShowAllData
    Not sure what I am doing wrong. Thank you for the help.

  4. #4
    Forum Contributor
    Join Date
    01-04-2011
    Location
    Phoenix, Arizona
    MS-Off Ver
    Excel 2003
    Posts
    129

    Re: Copy & Paste Filtered Data

    Chance2,

    I actually found the problem. I had to change the Autofilter Fiedl:=2 that is the differnce that was needed. Thank you very much for your help. That is a world better in time on for my program.

    I have similar questions for cut and paste on the same program, but that is a question for later. Thanks

    Kelly

+ 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