I have an Excel document that contains the following column data:
country, animal name, result ResultQuality is an indicator of how accurate the result in the line (ResultA- ResultZ), quality (1-6), result A, ResultB, ResultC ..... ResultQ
= 1, the low quality level result is quality = 6.
Here are some examples of lines:
line # 1: America, Camel, 1985,2, 111222333 ..... 999 Line # 2: US, Camel, 1985,114,227,338 ..... 958 Line # 3: Canada, Camel, 1985, 3, 214, 257,638 ..... 858 Line # 4: Canada, Shark, 1985, 1,14,27,38 ..... 8 line # 5: Canada, Shark, 1985,2, 14, 257,3 ..... 628 line # 6: Canada, Shark, 1985,4, 14,25, 63 ..... 568 Line # 7: Canada, Shark, 1985,6,14,25,6 ... 838 As you see, [ Country, animal name, year] key can have one or more rows, Looking results is the quality. Need a macro: Go to all the rows, and for each [country, animal name, year] key - Keep the other low quality rows for the highest quality result line After running the macro at the top 3 rows - the result should be:
line # 1: US, Camel, 1985,2, 111,222,333 ... 999 Line # 2: Canada, Camel, 1985, 3, 214, 257,638 ... 858 Line # 3: Canada, Shark, 1985, 14, 27, 38 ... 8. Thank you allocated! In fact, it can be completed without declaring a single variable. Duplicate removal works from top to bottom.
So, if the data is sorted properly and the appropriate columns are given to determine the duplicates, then the operation should be easy.
Sub Highest_Priority_Wight () with ActiveSheet.Cells (1, 1) .core regian 'This method can only use three key columns in one way so that we can do it twice. similarity. Survate key 1: =. Columns (4), Order 1: = XLsaking, _ Orientation: = xlTopToBottom, Header: = XlYes .ells.Sort Key1: = Columns (1), Order 1: = xlAscending, _KEY2: =. Column (2), Order2: = xlAscending, _KEY3: = Columns (3), Order 3: = XLSecing, _Status: = xlTopToBottom, Header: = xlYes' Now the best are on top, to clear all others Dedupe Delete Column: = Array (1, 2, 3), Header: With it should be turned on,
.. In something like this,
< Img src = "https://i.stack.imgur.com/rpiB.png" alt = "animal priority weight II">
For Excel, this is the fastest way I know. If you prefer some other display format then After a deleted duplicate operation
, a later sorting routine can be added.
No comments:
Post a Comment