Consulting

Results 1 to 8 of 8

Thread: List uniques from multiple worksheets

  1. #1
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location

    List uniques from multiple worksheets

    Hi everyone,


    I'm trying to do a advance Filter to look through multiple worksheets and copy the uniques into a summary sheet. I have this so far.

    [VBA]Sub sortandmove()
    Dim Rng As Range
    Dim i As Variant
    Dim wSht As Worksheet
    Application.ScreenUpdating = False
    Sheet5.Range("A2:A5000").ClearContents
    For Each wSht In ThisWorkbook.Worksheets
    If wSht.Name <> "Final List" Then
    'wSht.Activate
    wSht.Range("A1:B2000").AutoFilter field:=1, Criteria1:="<>"
    wSht.Range("A2:B2000").SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Final List").Range("A65536").End(xlUp).Offset(1, 0)
    wSht.AutoFilterMode = False
    End If
    Next wSht
    Application.ScreenUpdating = True
    End Sub[/VBA]

    I tried to add this [VBA], Unique:=True[/VBA] in line below but it does not work.


    [VBA]wSht.Range("A2:B2000").SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Final List").Range("A65536").End(xlUp).Offset(1, 0), Unique:=True
    [/VBA]
    SHAZAM!

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    I'm a bit confused.

    You say you are using Advanced Filter, but all I can see in the code is AutoFilter.

    I'm also not aware of any Unique argument for copying.

  3. #3
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Quote Originally Posted by Norie
    I'm a bit confused.

    You say you are using Advanced Filter, but all I can see in the code is AutoFilter.

    I'm also not aware of any Unique argument for copying.

    Sorry norie your right. Here is a macro record I did. But can it be modified to look through multiple worksheets and just copy the uniques and paste them in the "Final List" worksheet tab in column B?

    [vba]
    Columns("A:A").Select
    Range("A1:A7").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Columns( _
    "B:B"), Unique:=True
    [/vba]
    SHAZAM!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why not just copy all of the data, sheet by sheet, to the master sheet, and then filter that sheet for uniques?

  5. #5
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Quote Originally Posted by xld
    Why not just copy all of the data, sheet by sheet, to the master sheet, and then filter that sheet for uniques?
    The thing is the user enters the data daily in one of those worksheets ( 12 in Total ). So when the user finish there daily entry all the user has to do is run the macro and it will look through each worksheet and copy just the uniques and paste it into the "Final List" worksheet tab. Do think thats possible?
    SHAZAM!

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Of course it is, but what I was thinking that an item on one sheet might be duplicated on an other, so if you filter by sheet you won't catch that.

    Even if you add a sheet daily, you could still do it as I suggested. Repetition isn't going to hurt.

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Shazam,
    I'd basically follow XLD's suggestion. However, if you master sheet might contain duplicates, you could copy all to a new worksheet, filter and then cut and paste to the Master.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Quote Originally Posted by mdmackillop
    Hi Shazam,
    I'd basically follow XLD's suggestion. However, if you master sheet might contain duplicates, you could copy all to a new worksheet, filter and then cut and paste to the Master.
    Thanks mdmackillop xld, & Norie

    I'll do your suggestions. Right now I'm using a formula to look through the worksheets and returning unique values But the file keeps on growing and calculation is very slow.


    Thanks for the help everyone!
    SHAZAM!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •