- David
'Sort array
For lLoop = 0 To MyCollection.Count
For lLoop2 = lLoop To MyCollection.Count
If UCase(MyCollection(lLoop2)) < UCase(MyCollection(lLoop))
Then
str1 = MyCollection(lLoop)
str2 = MyCollection(lLoop2)
MyCollection(lLoop) = str2
MyCollection(lLoop2) = str1
End If
Next lLoop2
Next lLoop
HTH
Charles Chickering
Here's the original website if you want to read it as well:
http://www.ozgrid.com/VBA/sort-array.htm
If UCase(nodupes(lLoop2)) < UCase(nodupes(lLoop)) Then
any ideas why? Thanks.
- David
Charles
On Error Resume Next
For g = 1 To 669
If ActiveSheet.Cells(g, 1) <> Empty Then
nodupes.Add ActiveSheet.Cells(g, 1).Value,
CStr(ActiveSheet.Cells(g, 1).Value)
Else
End If
Next g
On Error GoTo 0
Just for refrence the names are in the format last name, first name
-David
Let me know if it works
Charles
Charles
-David
Charles
http://www.j-walk.com/ss/excel/tips/tip47.htm
Filling a ListBox With Unique Items
Unless you do a major modification of someone else's code it is usually
better to provide the link so the complete context can be seen by the OP.
--
Regards,
Tom Ogilvy
Charles
- David
then look in the object browser in the script library for the dictionary
object.
--
Regards,
Tom Ogilvy
"David" <pick...@gmail.com> wrote in message
news:1157677069.6...@i42g2000cwa.googlegroups.com...
Sub RemoveDupes()
Dim cnt As Long
Dim nodupes As Dictionary
Set nodupes = New Dictionary
For cnt = 1 To Range("C" & Rows.Count).End(xlUp).Row
If Not nodupes.Exists(CStr(ActiveSheet.Cells(cnt, 3).Value))
Then
nodupes.Add CStr(ActiveSheet.Cells(cnt, 3).Value), _
ActiveSheet.Cells(cnt, 3).Value
End If
Next
For cnt = 1 To nodupes.Count
Range("D" & cnt) = nodupes.Items(cnt - 1)
Next
End Sub
Let me know if you have problems
Charles
Charles Chickering
Try it this way
Sub RemoveDupes()
Dim cnt As Long
Dim nodupes As Scripting.Dictionary
Set nodupes = New Scripting.Dictionary
For cnt = 1 To Range("C" & Rows.Count).End(xlUp).Row
If Not nodupes.Exists(CStr(ActiveSheet.Cells(cnt, 3).Value)) Then
nodupes.Add CStr(ActiveSheet.Cells(cnt, 3).Value), _
ActiveSheet.Cells(cnt, 3).Value
End If
Next
For cnt = 1 To nodupes.Count
Range("D" & cnt) = nodupes.Items(cnt - 1)
Next
End Sub
if that is problematic, try it either of these ways:
Sub RemoveDupes()
Dim cnt As Long
Dim nodupes As Object
Set nodupes = CreateObject("Scripting.Dictionary")
For cnt = 1 To Range("C" & Rows.Count).End(xlUp).Row
If Not nodupes.Exists(CStr(ActiveSheet.Cells(cnt, 3).Value)) Then
nodupes.Add CStr(ActiveSheet.Cells(cnt, 3).Value), _
ActiveSheet.Cells(cnt, 3).Value
End If
Next
Range("D1").Resize(nodupes.Count, 1) = _
Application.Transpose(nodupes.Items)
End Sub
Sub RemoveDupes1()
Dim cnt As Long, v As Variant
Dim nodupes As Object
Set nodupes = CreateObject("Scripting.Dictionary")
For cnt = 1 To Range("C" & Rows.Count).End(xlUp).Row
If Not nodupes.Exists(CStr(ActiveSheet.Cells(cnt, 3).Value)) Then
nodupes.Add CStr(ActiveSheet.Cells(cnt, 3).Value), _
ActiveSheet.Cells(cnt, 3).Value
End If
Next
v = nodupes.Items
cnt = 1
For i = LBound(v) To UBound(v)
Range("D" & cnt).Value = v(i)
cnt = cnt + 1
Next
End Sub
--
Regards,
Tom Ogilvy
"David" <pick...@gmail.com> wrote in message
news:1157769284.1...@d34g2000cwd.googlegroups.com...
--
Regards,
Tom Ogilvy
"David" <pick...@gmail.com> wrote in message
news:1157871991....@h48g2000cwc.googlegroups.com...
- David
As I know, excel doesn't allow sorting of formula-driven values.
So, effectively, I need some option, function or code which takes these
formula-driven values and sort them, so that I can plot a pareto chart
Please clarify.
Thanks and regards
Mahesh
Can you give an example of formula values which do not permit sorting?
---
Regards,
Norman
"mahesh" <mahesh....@gmail.com> wrote in message
news:1159420621.4...@h48g2000cwc.googlegroups.com...
It's not exactly "formula values do not permit sorting", but "sorting
doesn't take formula fields". For example, if you have a list of 5
values in column A. Take the cumulative, for each cell, in the adjacent
column B. And take the percentage of each value corresponding to the
total value and place them in column C
Now select all the columns and sort by column A.
The result will be that only Col A will be sorted and not the other
two.
It is understood that, when you are selecting all the columns, all the
values should align accoridngly with the sorted col.
Could I answer you?
Thanks
Mahesh
=countif($B$1:B1,B1)
then drag fill down the column.
Select column C, do Edit=>Copy, then Edit=>Paste Special and select Values.
Now sort the data with column C as the first key, then column B as the
second key.
This is fairly trivial - make an effort. - pay attention to the
instructions.
--
Regards,
Tom Ogilvy
"Curt" <Cu...@discussions.microsoft.com> wrote in message
news:27D790BC-27F0-42F4...@microsoft.com...
=countif($C$1:C1,C1)
--
Regards,
Tom Ogilvy
"Tom Ogilvy" <twog...@msn.com> wrote in message
news:ulpxKmc...@TK2MSFTNGP06.phx.gbl...
for example, in your sample code you posted you do
for t = 2 to cells(100,3).End(xlup).Column step 8
cells(100,3).End(xlup).Column will always return 3, so your loop would
only do one pass.
you also select Range(Cells(t, 3), Cells(t + 3, 3)).Select
and then sort only the selection. This would sort C2:C5 on the one pass
you make, but you said you want to sort 8 cells. Also, it appears you want
to sort all the columns from A to T (you explanations are not that clear),
so you would not just sort column C alone.
I posted some corrections in that thread, but hopefully you can understand
that I don't particularly accept you answer that you triet it and it failed.
That may very well be, but it would work for the problem as I understood you
to described it (which may not be the problem).
--
Regards,
Tom Ogilvy
"Curt" <Cu...@discussions.microsoft.com> wrote in message
news:61C6E3FA-2568-475A...@microsoft.com...
--
Regards,
Tom Ogilvy
"Curt" <Cu...@discussions.microsoft.com> wrote in message
news:F6367ACD-A02B-4396...@microsoft.com...
Here are a copy paste from a worksheet need the columns to sort 12345678. as
you can see I have been trying. So far no luch
Thanks
so you don't have an equal number of each value (1 to 8)
How do you want them sorted (assume the first 1 is in C2 for each case)
1 2 3 4 5
6 7 8 1 2
3 4 5 6 7
or
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
what to do about incomplete sets?
and, this cetainly doesn't match any of your descriptions or your code.
If you have complete sets, you might as well regenerate them
i = 0
for each cell in Range("C2").Resize(16,5)
i = i + 1
if i > 8 then i = 1
cell = i
Next
or
i = 0
for each cell in range("C2:C17")
i = i + 1
if i > 8 then i = 1
cell.Resize(1,5).Value = i
Next
--
Regards,
Tom Ogilvy
"Curt" <Cu...@discussions.microsoft.com> wrote in message
news:69241075-7D15-422D...@microsoft.com...
End Sub
produced:
1 1 1 1 1
2 2 2 2 2
3 8 3 3 3
4 1 4 4 4
5 2 5 5 5
6 1 6 6 6
7 2 7 7 7
8 1 8 8 8
1 2 1 1 1
2 1 2 2 2
3 2 3 3 3
4 1 4 4 4
6 2 5 5 5
7 1 6 6 6
8 2 8 7 7
7 1 8
with your test data.
Use the method I originally advised, applied to the multicolumn layout of
your data and the statement (as I understood it) that you wanted each column
sorted separately. As I understand it, that is what you want.
--
Regards,
Tom Ogilvy
"Curt" <Cu...@discussions.microsoft.com> wrote in message
news:640AAFD1-9C78-4AE6...@microsoft.com...