Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Create unique list from four lists

I need a macro that takes four lists of people on the spreadsheet and creates
a single list of unique names, sorted alphabetically. The four ranges of
lists of people a D11:D19, L11:L19, D26:D34, L26:L34. I need to paste the
unique list of names starting in cell D39. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 284
Default Create unique list from four lists

Assuming you want to sort alphabetical based on the first letter in each of
the cells, this is one option. It's probably more efficient to let Excel do
the sort rather than create the ADOR.Recordset but this should do the trick.

Steve Yandl

_________________________________________________

Sub GrabUniqueNames()

Const adVarChar = 200
Const MaxCharacters = 255

Dim strName As String
Dim nameArray()

Set objDic = CreateObject("Scripting.Dictionary")

For N = 11 To 19
strName = CStr(Cells(N, 4).Value)
If Not objDic.Exists(strName) Then
objDic.Add strName, strName
End If
strName = CStr(Cells(N, 12).Value)
If Not objDic.Exists(strName) Then
objDic.Add strName, strName
End If
Next N

For N = 26 To 34
strName = CStr(Cells(N, 4).Value)
If Not objDic.Exists(strName) Then
objDic.Add strName, strName
End If
strName = CStr(Cells(N, 12).Value)
If Not objDic.Exists(strName) Then
objDic.Add strName, strName
End If
Next N

If objDic.Count 0 Then
nameArray = objDic.Keys
End If

Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "myNames", adVarChar, MaxCharacters
DataList.Open

For m = 0 To UBound(nameArray)
DataList.AddNew
DataList("myNames") = nameArray(m)
DataList.Update
Next m

DataList.Sort = "myNames"

R = 39
DataList.MoveFirst
Do Until DataList.EOF
Cells(R, 4).Value = DataList.Fields.Item("myNames")
R = R + 1
DataList.MoveNext
Loop

Set objDic = Nothing
Set DataList = Nothing
End Sub

_______________________________________________

"Bill_S" wrote in message
...
I need a macro that takes four lists of people on the spreadsheet and
creates
a single list of unique names, sorted alphabetically. The four ranges of
lists of people a D11:D19, L11:L19, D26:D34, L26:L34. I need to paste
the
unique list of names starting in cell D39. Thanks.



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
create a list of unique values Bill Brehm Excel Worksheet Functions 4 February 29th 08 01:50 AM
sumproduct to create a unique list Excel 2003 - SPB Excel Discussion (Misc queries) 9 September 9th 07 09:27 PM
Create list of unique entries for use in validation raphiel2063 Excel Worksheet Functions 5 September 6th 07 04:49 AM
How to create a list of unique dates? Eric Excel Discussion (Misc queries) 6 June 15th 07 04:48 AM
Merging to Lists into one Unique List Rob Excel Discussion (Misc queries) 4 September 21st 06 03:12 AM


All times are GMT +1. The time now is 08:17 PM.

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"