Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

Remove duplicates without shifting cells

$
0
0

I have an Excel sheet with two columns, one contains the name of an issue on a computer and the other the concatenated serial numbers of the computers with this issue.

The point of the Excel sheet is to find the best combination of issues to fix in priority, i.e. the most present combination of issues among the computer park.

Here is a data sample:

Issue          Serials
Dead SSD     SN0125;
Dead CPU     SN0125;SN0452;
Dead Screen  SN0785;SN0452;SN0125;
Dead Ram     SN0785;SN0452;SN0658;SN0125;SN0111

This means that SN0125 will be reusable after we've fixed it's SSD, while SN0111 will be reusable after we've fixed it's ram, screen, cpu and SSD.
There isn't any pattern nor order in the concatenation of serials.

I want, if a Serial appears in a row, it shouldn't appear in the rows beneath, so I get something like this.

Issue          Serials
Dead SSD     SN0125;
Dead CPU     SN0452;
Dead Screen  SN0785;
Dead Ram     SN0658;SN0111;

I tried looping through the rows and remove duplicate serials using replace but ended up with empty serial cells.
Here is the code i tried:

For i = 2 To las_row
    s1 = Cells(i, 2)

    For j = i To las_row
        'We look for the content of the previous row, inside the next and remove it
        s2 = Cells(j, 2)
        Cells(i, 2) = Replace(s1, s2, "")
    Next j
Next i

Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>