Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have a list in Excel that contains records with duplicate numbers. I am trying to filter this list via VBA to retrieve only unique records and place that list on another sheet in the same wb. I have given the column that contains the duplicate numbers a dynamic named range with the following formula: dub_range=OFFSET($A$1,0,0,COUNTA($A:$A)) The VBA code, which I found on ozgrid is listed below. When I run this code it seems to work, except that for some reason the very first item in the list is returned at the very top of my filtered list, regardless of where it would normally appear in a sorted list and it also appears in the list where it normally should appear in a sorted list. Sub UniqueList() Dim rListSort As Range, rOldList As Range Dim strListFill As String 'Clear Hidden sheet Column A ready for list Sheet8.Range("N1", Sheet8.Range("N65536").End(xlUp)).Clear 'Set range variable to list we want Set rOldList = Sheet2.Range("PO_Number") 'Use AdvancedFilter to copy the list to Column A _ of the hidden sheet and remove all dupes rOldList.AdvancedFilter Action:=xlFilterCopy, _ CopyToRange:=Sheet8.Cells(1, 14), Unique:=True 'Set range variable to the new non dupe list Set rListSort = Sheet8.Range("N1", Sheet8.Range("N65536").End(xlUp)) 'Sort the new non dupe list With rListSort .Sort Key1:=Range("N1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End With strListFill = Sheet8.Name & "!" & Sheet8.Range _ ("N1", Sheet8.Range("N65536").End(xlUp)).Address Sheet8.cbo_PO.ListFillRange = vbNullString Sheet8.cbo_PO.ListFillRange = strListFill End Sub All help is greatly appreciated. Thanks in advance. Regards, A. Crawford |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I delete unique numbers from a list and save duplicates? | Excel Worksheet Functions | |||
Array Offset() formula with height of 1 returns duplicates? | Excel Worksheet Functions | |||
Array Formulas - Unique List from List with Duplicates | Excel Discussion (Misc queries) | |||
Question about what the Find function returns if the item wasn't found | Excel Programming | |||
Add Unique item to Collection | Excel Programming |