Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default List of values / unique problem

Hi,

This macro I use to create a list of unique values in a certain range. But,
values that look like each other, are not shown in my list. For example:
"red apple" and "apple" as values are seen as one, so apple will not be in
the list. How should I change it, so that every unique value is in my list?

Thanks, Gert-Jan

Dim rngData As Range
Dim strThisItem As String
Dim strUnqItms As String
Dim strTempAry() As String
Dim itm As Variant
For Each rngData In Worksheets("database").Range("B1:B100")
If rngData = "" Then Exit For
strThisItem = rngData
If InStr(strUnqItms, strThisItem) = 0 Then
strUnqItms = strUnqItms & "," & strThisItem
End If
Next rngData
strTempAry = Split(strUnqItms, ",")
Set rngData = Worksheets("sheets2").Range("J1")
For Each itm In strTempAry
If itm < "" Then
rngData = itm
Set rngData = rngData.Offset(1, 0)
End If
Next itm
End If


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default List of values / unique problem

I found a good solution:

Sub FilterUniqueNumbers()
Dim rngYourrange As Range
Dim rngCell As Range
Dim colUniqueNumbers As New Collection
Dim i As Integer
Set rngYourrange = Worksheets("database").Range("B1:B30")
On Error Resume Next
For Each rngCell In rngYourrange
colUniqueNumbers.Add rngCell.Value, CStr(rngCell.Value)
Next rngCell
For i = 1 To colUniqueNumbers.Count
Worksheets("sheet1").Cells(i, 2).Value = colUniqueNumbers(i)
Next i
End Sub


"Gert-Jan" schreef in bericht
...
Hi,

This macro I use to create a list of unique values in a certain range.
But, values that look like each other, are not shown in my list. For
example: "red apple" and "apple" as values are seen as one, so apple will
not be in the list. How should I change it, so that every unique value is
in my list?

Thanks, Gert-Jan

Dim rngData As Range
Dim strThisItem As String
Dim strUnqItms As String
Dim strTempAry() As String
Dim itm As Variant
For Each rngData In Worksheets("database").Range("B1:B100")
If rngData = "" Then Exit For
strThisItem = rngData
If InStr(strUnqItms, strThisItem) = 0 Then
strUnqItms = strUnqItms & "," & strThisItem
End If
Next rngData
strTempAry = Split(strUnqItms, ",")
Set rngData = Worksheets("sheets2").Range("J1")
For Each itm In strTempAry
If itm < "" Then
rngData = itm
Set rngData = rngData.Offset(1, 0)
End If
Next itm
End If



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
Formula (not adv. filter) to list unique values from list Brian Excel Worksheet Functions 3 May 12th 09 04:33 AM
Identify & List unique values from a list using functions/formulas momtoaj Excel Worksheet Functions 3 May 31st 07 06:18 PM
Unique Values in a list PGalla06[_16_] Excel Programming 2 September 20th 05 04:42 PM
Count unique values and create list based on these values vipa2000 Excel Worksheet Functions 7 August 5th 05 01:17 AM
create list of unique values from a column with repeated values? Chad Schaben Excel Worksheet Functions 1 July 8th 05 10:25 PM


All times are GMT +1. The time now is 06:42 AM.

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"