Autofilter (in a macro) problem

B

BrianR

I'm using the autofilter feature from a macro
(see below).

One last issue, when I run this AutoFilter macro, it keeps putting the first
unique ID (607) found (from column A) into my new ID List twice. It only
does it
for the first item.

ID List
607
607
614
615
616

Public Sub ExtractUniqueAndSort(Sheet As String, last_row_used_local As
Integer)
Dim destcell As String

destrow = 4
destcell = Sheets(Sheet).Cells(destrow, ID_List).Address

With Sheets(Sheet)
'extract unique IDs from column A
Range("A2:A" & last_row_used_local).AdvancedFilter
Action:=xlFilterCopy, _
CopyToRange:=Sheets(Sheet).Cells(destrow, ID_List), Unique:=True

'sort the unique IDs
.Range(.Range(destcell), .Range(destcell).End(xlDown)) _
.Sort Key1:=.Range(destcell), Order1:=xlAscending, Header:=xlYes
End With

End Sub
 
D

Dave Peterson

See your other thread.
I'm using the autofilter feature from a macro
(see below).

One last issue, when I run this AutoFilter macro, it keeps putting the first
unique ID (607) found (from column A) into my new ID List twice. It only
does it
for the first item.

ID List
607
607
614
615
616

Public Sub ExtractUniqueAndSort(Sheet As String, last_row_used_local As
Integer)
Dim destcell As String

destrow = 4
destcell = Sheets(Sheet).Cells(destrow, ID_List).Address

With Sheets(Sheet)
'extract unique IDs from column A
Range("A2:A" & last_row_used_local).AdvancedFilter
Action:=xlFilterCopy, _
CopyToRange:=Sheets(Sheet).Cells(destrow, ID_List), Unique:=True

'sort the unique IDs
.Range(.Range(destcell), .Range(destcell).End(xlDown)) _
.Sort Key1:=.Range(destcell), Order1:=xlAscending, Header:=xlYes
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top