Sort out the most unique data

doharr

Board Regular
Joined
Jul 28, 2009
Messages
77
Have DATA in one column:
1487 replaces 1487P
1508 replaces 1508P
1518 replaces 2809, 47-7900, 703247
1518 replaces 47-7900, 703247
1518 replaces 703247
1521 replaces 1521P
1528 replaces 208173, 252-88, 47-9600, 705478
1528 replaces 252-88, 47-9600, 705478
1528 replaces 47-9600, 705478
1528 replaces 705478
1535 replaces 1535P
3715 replaces 3139, 5234, 7582, 7585
3715 replaces 5234, 7582, 7585

Only want to keep the most unique data:
1487 replaces 1487P
1508 replaces 1508P
1518 replaces 2809, 47-7900, 703247
1521 replaces 1521P
1528 replaces 208173, 252-88, 47-9600, 705478
1535 replaces 1535P
3715 replaces 3139, 5234, 7582, 7585

Need help on a VBA code to sort out the most unique data.
Thank you in advance for any help.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
The way your sample data is presented, you seem to just want each row where the number at the start changes. So, assuming...

1. Data is in column A, starting in row 2 (allowing for heading in row 1)

2. Columns B and C are vacant

3. All the leading numbers are 4 digits.

4. You just want the first occurrance of each 4 digit number

... then try this. If any of my assumptions are incorrect or this doesn't do what you want for some reason, then please provide more details.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> doharr()<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Range("C1:C" & Range("A" & Rows.Count).End(xlUp).row)<br>        .Value = .Offset(, -2).Value<br>        <SPAN style="color:#00007F">With</SPAN> .Offset(1, -1)<br>            .FormulaR1C1 = "=IF(LEFT(RC[-1],4)=LEFT(R[-1]C[-1],4),1,"""")"<br>            <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>            .SpecialCells(xlCellTypeFormulas, xlNumbers).Offset(, 1).Delete shift:=xlUp<br>            <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0<br>            .ClearContents<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        .EntireColumn.AutoFit<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top