Results 1 to 3 of 3

Copy unique values from autofilter

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
    3,963

    Copy unique values from autofilter

    On my "View2Pivot" worksheet I have an autofilter applied. I want to copy only the unique, visible items from the second column in my autofilter range. I was hoping this code would do it for me, but I'm getting an error message saying "Object Variable or With Block Variable not set"

    Worksheets("View2Pivot").AutoFilter.Range.Columns(2).AdvancedFilter Action:=xlFilterCopy, _
       CopyToRange:=Wks.Range("F:F"), Unique:=True
    Here's the full macro:
    Sub PertPacsOne()
    Dim Rng As Range
    Dim Wks As Worksheet
    
    Set Wks = Worksheets("Lookups")
    Set Rng = Wks.Range(Wks.Cells(2, "F"), Wks.Cells(Rows.Count, "F").End(xlUp))
    
    Wks.Range("F:F").ClearContents
    Worksheets("View2Pivot").AutoFilter.Range.Columns(2).AdvancedFilter Action:=xlFilterCopy, _
       CopyToRange:=Wks.Range("F:F"), Unique:=True
    
        
        ThisWorkbook.Names.Add "PertPacs1", Rng
        Addx = Range("PertPacs1").Address
    
    End Sub
    Last edited by jomili; 12-07-2010 at 06:39 PM.

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