+ Reply to Thread
Results 1 to 9 of 9

Extract unique values from range

Hybrid View

esbencito Extract unique values from... 09-26-2018, 05:36 AM
Sintek Re: Extract unique values... 09-26-2018, 07:19 AM
esbencito Re: Extract unique values... 09-26-2018, 11:05 PM
czl103 Re: Extract unique values... 09-26-2018, 11:18 PM
AlKey Re: Extract unique values... 09-26-2018, 11:53 PM
EXCELBENCH Re: Extract unique values... 09-30-2018, 06:38 AM
protonLeah Re: Extract unique values... 09-27-2018, 12:03 AM
Sintek Re: Extract unique values... 09-27-2018, 12:32 AM
esbencito Re: Extract unique values... 09-27-2018, 01:38 AM
  1. #1
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    Re: Extract unique values from range

    Thanks all! I ended up with a mix of both solutions and it seems to work just fine!

    Sub GetSeasonCodes()
        
        Dim LR As Long
        Dim SS_Codes As Variant
        
        Application.ScreenUpdating = False
        Application.Calculation = xlCalculationManual
        
        LR = Sheets("Recap").Cells(Rows.Count, Range("Attribute_SuperSeason").Column).End(xlUp).Row
        Sheets("Control").Range("A3").EntireColumn.ClearContents
    
        Sheets("Recap").Range("" & ColName(Range("Attribute_SuperSeason")) & "1").Resize(RowSize:=LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("Control").Range("A3"), Unique:=True
            
        Sheets("Control").Range("A3").Delete Shift:=xlUp
        
        Sheets("Control").Range("A3:A10").Sort Key1:=Sheets("Control").Range("A3"), Order1:=xlAscending, Header:=xlNo
            
        SS_Codes = WorksheetFunction.Transpose(Sheets("Control").Range("A3:A5").Value)
        
        Sheets("Control").Range("A3").EntireColumn.ClearContents
        
        Sheets("Recap").Range(Sheets("Recap").Cells(1, 1), Sheets("Recap").Cells(1, Columns.Count)).AutoFilter
        
        MsgBox SS_Codes(1) & "   " & SS_Codes(2) & "   " & SS_Codes(3)
        
        Application.Calculation = xlCalculationAutomatic
        Application.ScreenUpdating = True
    
    End Sub
    Didn't know that the advanced filter method is common to use in VBA to find unique values. It's probably even a lot faster than some of the other array calculations...
    Last edited by esbencito; 09-27-2018 at 01:40 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 10-27-2016, 07:33 PM
  2. [SOLVED] Extract Unique values in range
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-08-2014, 06:39 AM
  3. Replies: 2
    Last Post: 02-13-2013, 03:14 PM
  4. Replies: 3
    Last Post: 11-24-2011, 06:11 AM
  5. Replies: 3
    Last Post: 09-20-2011, 05:05 PM
  6. Extract Unique Values, Then Extract Again to Remove Suffixes
    By Karl Burrows in forum Excel General
    Replies: 23
    Last Post: 06-25-2005, 08:05 PM

Tags for this Thread

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