Showing posts with label Display Unique Rows using Advanced Filter Excel VBA. Show all posts
Showing posts with label Display Unique Rows using Advanced Filter Excel VBA. Show all posts

Sunday, July 20, 2008

Create Advanced Filter in Excel VBA for making the range with unique records

Make Range Unique using Advanced Filter in Excel VBA

Advanced Filter cane be used for making the range with unique records. The following snippet should be useful for the same.

Sub Make_Unique_List_InPlace()

Dim oWS As Worksheet ' Worksheet Object

Dim oRange As Range ' Range Object - Contains Represents the List of Items that need to be made unique

On Error GoTo Disp_Error

' ---------------------------------------------

' Coded by Shasur for www.vbadud.blogspot.com

' ---------------------------------------------

Set oRange = Range("B:B")

oRange.AdvancedFilter(Action:=xlFilterInPlace, Unique:=True)

If Not oRange Is Nothing Then oRange = Nothing

If Not oWS Is Nothing Then oWS = Nothing

' --------------------

' Error Handling

' --------------------

Disp_Error:

If Err <> 0 Then

MsgBox(Err.Number & " - " & Err.Description, vbExclamation, "VBA Tips & Tricks Examples")

Err.Clear()

Resume Next

End If

End Sub

oRange.AdvancedFilter filters or copies data from a list based on a criteria range. If the initial selection is a single cell, that cell's current region is used. The above code does not physically delete duplicate records from the sheet/range


Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.