Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Autofilter (in a macro) problem

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Autofilter (in a macro) problem

See your other thread.

BrianR wrote:

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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
autofilter problem Tonso Excel Discussion (Misc queries) 8 November 19th 06 05:22 PM
Problem with Autofilter Jaan Excel Discussion (Misc queries) 6 February 8th 06 06:39 AM
Autofilter problem Tom Ogilvy Excel Programming 1 June 2nd 05 07:28 PM
autofilter problem emre Excel Worksheet Functions 0 March 29th 05 10:19 PM
Now problem with autofilter James Stephens Excel Programming 3 January 14th 04 07:50 PM


All times are GMT +1. The time now is 06:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"