Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Autofilter question

If you run an autofilter in column A and the drop down shows:
Adam
Bob
Dave
George
Mark
Steven
etc

Is there a way to reference Adam as 1 or something? Bob would be 2 Dave
would be 3 etc.

What I'm thinking is something like autofilter A and then criteria
would be Adam so I can copy and paste to a new sheet. Right now I have
maybe 800 different names and I'm trying to figure out an easier way to
move each individual entry and the number will only go up.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Autofilter question

The drop down list in auto-filter is an internal Excel function which you
cannot access other than through the user-interface. You could try using
the advanced filter and copy the result to another location removing
duplicates by selecting unique records only, then sorting the list ? Or in
VBA you create a new collection and sort that, collections do not allow
duplicate keys. Example follows...where a collection called 'NoDupes' is
created, and sorted

Sub RemoveDuplicates()
Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection
Dim i As Integer, j As Integer
Dim Swap1, Swap2, Item

' The items list are in A2:A106
Set AllCells = Range("A2:A106")

' The next statement ignores the error caused
' by attempting to add a duplicate key to the collection.
' The duplicate is not added - which is just what we want!

On Error Resume Next
For Each Cell In AllCells
If Not Cell.EntireRow.Hidden Then
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a string
End If
Next Cell

' Resume normal error handling
On Error GoTo 0

' Sort the collection (optional)
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) NoDupes(j) Then
Swap1 = NoDupes(i)
Swap2 = NoDupes(j)
NoDupes.Add Swap1, befo=j
NoDupes.Add Swap2, befo=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i
End Sub

--
Cheers
Nigel



"JeffMelton" wrote in message
ups.com...
If you run an autofilter in column A and the drop down shows:
Adam
Bob
Dave
George
Mark
Steven
etc

Is there a way to reference Adam as 1 or something? Bob would be 2 Dave
would be 3 etc.

What I'm thinking is something like autofilter A and then criteria
would be Adam so I can copy and paste to a new sheet. Right now I have
maybe 800 different names and I'm trying to figure out an easier way to
move each individual entry and the number will only go up.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Autofilter question

Insert a <<new column to the left of the Name Column
and enter (same row as first record name which is in say d4) into c4
=subtotal(3,$D$4:D4) and Copy down to D804. This should furnish
sequential numbering whether your table is filtered or not, and whether
rows are added or deleted.
HTH
Jim May

"JeffMelton" wrote in message
ups.com...
If you run an autofilter in column A and the drop down shows:
Adam
Bob
Dave
George
Mark
Steven
etc

Is there a way to reference Adam as 1 or something? Bob would be 2 Dave
would be 3 etc.

What I'm thinking is something like autofilter A and then criteria
would be Adam so I can copy and paste to a new sheet. Right now I have
maybe 800 different names and I'm trying to figure out an easier way to
move each individual entry and the number will only go up.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Autofilter question

You can use the code from John Walkenbach's site posted by Nigel to get a
unique list, or you can use code from Ron de Bruin's site which includes code
to do the copying as well.

http://www.rondebruin.nl/copy5.htm

--
Regards,
Tom Ogilvy


"Nigel" wrote:

The drop down list in auto-filter is an internal Excel function which you
cannot access other than through the user-interface. You could try using
the advanced filter and copy the result to another location removing
duplicates by selecting unique records only, then sorting the list ? Or in
VBA you create a new collection and sort that, collections do not allow
duplicate keys. Example follows...where a collection called 'NoDupes' is
created, and sorted

Sub RemoveDuplicates()
Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection
Dim i As Integer, j As Integer
Dim Swap1, Swap2, Item

' The items list are in A2:A106
Set AllCells = Range("A2:A106")

' The next statement ignores the error caused
' by attempting to add a duplicate key to the collection.
' The duplicate is not added - which is just what we want!

On Error Resume Next
For Each Cell In AllCells
If Not Cell.EntireRow.Hidden Then
NoDupes.Add Cell.Value, CStr(Cell.Value)
' Note: the 2nd argument (key) for the Add method must be a string
End If
Next Cell

' Resume normal error handling
On Error GoTo 0

' Sort the collection (optional)
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) NoDupes(j) Then
Swap1 = NoDupes(i)
Swap2 = NoDupes(j)
NoDupes.Add Swap1, befo=j
NoDupes.Add Swap2, befo=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i
End Sub

--
Cheers
Nigel



"JeffMelton" wrote in message
ups.com...
If you run an autofilter in column A and the drop down shows:
Adam
Bob
Dave
George
Mark
Steven
etc

Is there a way to reference Adam as 1 or something? Bob would be 2 Dave
would be 3 etc.

What I'm thinking is something like autofilter A and then criteria
would be Adam so I can copy and paste to a new sheet. Right now I have
maybe 800 different names and I'm trying to figure out an easier way to
move each individual entry and the number will only go up.




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 Question kate Excel Discussion (Misc queries) 0 April 25th 08 07:13 PM
AutoFilter Question AccessHelp Excel Discussion (Misc queries) 2 September 29th 06 09:25 PM
Autofilter Question k9nny Excel Discussion (Misc queries) 1 February 28th 06 07:52 PM
AUTOFILTER QUESTION Dan Excel Programming 1 March 2nd 05 04:36 PM
Question about Autofilter... Richard Latter New Users to Excel 3 February 28th 05 04:41 PM


All times are GMT +1. The time now is 11:10 AM.

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

About Us

"It's about Microsoft Excel"