Automated deletion of identified information

Mllam

New Member
Joined
Feb 16, 2022
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Good morning Everyone,

I have been asked of what seems like a simple task but is complex when talking about possibly 100k+ instances.

The issue: The data currently has mistakes and the mistakes have been identified and could be seen here -

data clean.xlsx
AB
1NameSkus
2ABA34X-T23
3ABA34X-T24
4ABA34X-T25
5ABA34X-T26
6ZECAM3-567
7ZECAM3-568
8BARBAR-ME3
9BARBAR-ME4
10BARBAR-ME5
11BARBAR-ME6
12BARBAR-ME7
Sheet1


The existing data where the mistakes are:

data clean.xlsx
ABCDEFGHIJK
15Original Data
16333-XTRABA34X-T23HUNHUN-R32ZECAM3-567
17332-XT1BARBAR-ME3BARBAR-ME4
18397-HN2HUNHUN-432ABA34X-T24ZECAM3-568BARBAR-ME5
19XTR-345ABA34X-T25BARBAR-ME6HUNHUN-TE5BARBAR-ME7ABA34X-T26
Sheet1


The expected results:

data clean.xlsx
ABC
22Expected Result
23333-XTRHUNHUN-R32
24332-XT1
25397-HN2HUNHUN-432
26XTR-345HUNHUN-TE5
Sheet1


Please let me know if there's a formula to complete this task or if I should post this issue in an alternate location on this forum.

Thank you in advance and regards,

Marco
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Bump. Anyone have a suggestion? Or a different way of viewing this?
 
Upvote 0
sumeven.xlsm
ABCDEFGHIJK
1NameSkus
2ABA34X-T23
3ABA34X-T24
4ABA34X-T25
5ABA34X-T26
6ZECAM3-567
7ZECAM3-568
8BARBAR-ME3
9BARBAR-ME4
10BARBAR-ME5
11BARBAR-ME6
12BARBAR-ME7
13
14
15Original Data
16333-XTRABA34X-T23HUNHUN-R32ZECAM3-567
17332-XT1BARBAR-ME3BARBAR-ME4
18397-HN2HUNHUN-432ABA34X-T24ZECAM3-568BARBAR-ME5
19XTR-345ABA34X-T25BARBAR-ME6HUNHUN-TE5BARBAR-ME7ABA34X-T26
20
21
22Expected Result
23333-XTRHUNHUN-R32        
24332-XT1          
25397-HN2HUNHUN-432        
26XTR-345HUNHUN-TE5        
Sheet2
Cell Formulas
RangeFormula
B23:K26B23=IFERROR(IF(INDEX(16:16,AGGREGATE(15,6,COLUMN($B16:$K16)/(COUNTIF($A$2:$B$12,$B16:$K16)=0),COLUMNS($A:A)))=0,"",INDEX(16:16,AGGREGATE(15,6,COLUMN($B16:$K16)/(COUNTIF($A$2:$B$12,$B16:$K16)=0),COLUMNS($A:A)))),"")
 
Upvote 0
possibly 100k+ instances.
I suspect that a formula approach with that much data might be a bit cumbersome.

Here is a possible macro approach. It would need some modification once we knew how to decide the extent of the data. Currently I have coded it to the ranges shown in your sample data to see if the concept is correct.

VBA Code:
Sub Mllam()
  Dim d As Object
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long, uba2 As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  a = Range("A1").CurrentRegion.Value
  For i = 2 To UBound(a)
    d(a(i, 1) & "|" & a(i, 2)) = 1
  Next i
  a = Range("A16").CurrentRegion.Value
  uba2 = UBound(a, 2)
  ReDim b(1 To UBound(a), 1 To uba2)
  b(1, 1) = "Result"
  For i = 2 To UBound(a)
    b(i, 1) = a(i, 1)
    k = 0
    For j = 2 To uba2 Step 2
      If IsEmpty(a(i, j)) Then Exit For
      If Not d.exists(a(i, j) & "|" & a(i, j + 1)) Then
        k = k + 2
        b(i, k) = a(i, j): b(i, k + 1) = a(i, j + 1)
      End If
    Next j
  Next i
  Range("A" & Rows.Count).End(xlUp).Offset(3).Resize(UBound(b), uba2).Value = b
End Sub


My sample data in rows 1:19, macro results in rows 22+

Mllam.xlsm
ABCDEFGHIJKL
1NameSkus
2ABA34X-T23
3ABA34X-T24
4ABA34X-T25
5ABA34X-T26
6ZECAM3-567
7ZECAM3-568
8BARBAR-ME3
9BARBAR-ME4
10BARBAR-ME5
11BARBAR-ME6
12BARBAR-ME7
13
14
15Original Data
16333-XTRABA34X-T23HUNHUN-R32ZECAM3-567
17332-XT1BARBAR-ME3BARBAR-ME4
18397-HN2HUNHUN-432ABA34X-T24ZECAM3-568BARBAR-ME5
19XTR-345ABA34X-T25BARBAR-ME6HUNHUN-TE5BARBAR-ME7ABA34X-T26
20
21
22Result
23333-XTRHUNHUN-R32
24332-XT1
25397-HN2HUNHUN-432
26XTR-345HUNHUN-TE5
27
Mistakes
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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