please check SHEET2.jpg
please check SHEET2.jpg
Last edited by raj soni; 11-28-2014 at 01:44 PM.
Are you saying that you would like the number in column "E" that relates to the Unique row of data in the same row, columns "A to D", to be placed against the same Combinations after the sort.
yes sir
exactly ,
Try this:-
Its a bit slow approx 30Secs, if too slow, I'll rewrite using arrays ???
Regards Mick![]()
Sub MG29Nov00 'Range Code Dim Rng As Range, n As Long, nn As Long Dim Dn As Range, c As Long, Stg As String Dim RngAc As Range, Ac As Range Dim Dic As Object, Q As Variant Dim Shts As Variant, Sh As Variant, G As Variant Dim nDic As Object Dim t t = Timer Shts = Array(1, 2, 3, 4) For Each Sh In Shts Set Dic = CreateObject("Scripting.Dictionary") Dic.CompareMode = 1 Set RngAc = Sheets("Order").Range("A1:D1") For Each Ac In RngAc If Not Dic.Exists(Ac.Value) Then Set Dic(Ac.Value) = CreateObject("Scripting.Dictionary") End If With Sheets("Order") Set Rng = .Range(.Cells(Ac.Offset(1).Row, Ac.Column), .Cells(Rows.Count, Ac.Column).End(xlUp)) End With For Each Dn In Rng If Not Dic(Ac.Value).Exists(Dn.Value) Then Dic(Ac.Value).Add (Dn.Value), 0 Next Dn Next Ac Set RngAc = Sheets(Sh).Range("A1:D1") Set nDic = CreateObject("Scripting.Dictionary") nDic.CompareMode = 1 'Ref# With Sheets(Sh) Set Rng = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp)) End With For Each Dn In Rng With Application Stg = Join(.Transpose(.Transpose(Dn.Resize(, 4).Value))) End With nDic.Item(Stg) = Dn.Offset(, 4) Next Dn 'Ref# For Each Ac In RngAc With Sheets(Sh) Set Rng = .Range(.Cells(Ac.Offset(1).Row, Ac.Column), .Cells(Rows.Count, Ac.Column).End(xlUp)) End With For Each Dn In Rng If Dic(Ac.Value).Exists(Dn.Value) Then Dic(Ac.Value).Item(Dn.Value) = Dic(Ac.Value).Item(Dn.Value) + 1 End If Next Dn c = 1 For Each G In Dic(Ac.Value) For nn = 1 To Dic(Ac.Value).Item(G) c = c + 1 Sheets(Sh).Cells(c, Ac.Column) = G Next nn Next G Next Ac 'Ref# Add With Sheets(Sh) Set Rng = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp)) End With For Each Dn In Rng With Application Stg = Join(.Transpose(.Transpose(Dn.Resize(, 4).Value))) End With Dn.Offset(, 4) = nDic.Item(Stg) Next Dn 'Ref# Add Next Sh MsgBox Timer - t End Sub
sir , thanks for trying , but this one is giving totally different result .
its copying down data
The code that you said was OK is basically the same as the code you say is not OK. The results from both codes, to me seem the same.
To clarify what you require Please supply an example of you Basic data, and an Example of what you expect to see when the code has run.
The sample need to be large enough to ensure there is no ambiguity.
hello sir , sorry for trouble.
don't know why its not working now ,
i have attach before and after sample file .
1 ) sheet "order" has values how custom sort order should appear .
2 ) sheet 1 to 4 has 5 different headers in a1:e1
3 ) headers in this 4 sheets are placed differently .
3 ) in every 4 sheets , we have to
custom sort
column A first according to its header A1
then column b according to its header B1,
then column c according to its header C1
then column d according to its header D1
then column e according to its header E1
according to order we have referenced in ORDER sheet .
4 ) most interesting part is here , column f has id number ....here we need to expand selection , no need to sort .
for example i have mark id : 91 .....in all 4 sheets .
if you check values corresponding to 91 ....all are same but in differently place .
Earth April Tuesday Red Cucumber 91...............SHEET1
Red Tuesday Earth April Cucumber 91...............SHEET2
Tuesday Earth April Cucumber Red 91...............SHEET3
Cucumber Earth Red Tuesday April 91...............SHEET4
all values of combination are same , but combination are different
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks