delete entire row on contiguous duplicates

ninez87

New Member
Joined
Aug 5, 2017
Messages
7
hi i need help about cleaning entire row from this data output

Conditions required

Run a loop searching for the word "Speciale" in column A1
If found (looking if b2 = "Quantita" and deletes row b1)




in red is what i need to delete
Some can help me ?

A B
[TABLE="width: 464"]
<tbody>[TR]
[TD]Speciale 175377.2 QG #LDP 2443 #AVP 4748[/TD]
[TD]Quantita[/TD]
[/TR]
[TR]
[TD]ECEPI443[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]EPILZ750103[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6AV21232DB030AX0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES72151AG400XB0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES72231BL320XB0[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]ESI6ES79548LC020AA0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]EDATTHQQS00[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Speciale 175427 QG #LDP 2442 #AVP 4726[/TD]
[TD]Quantita[/TD]
[/TR]
[TR]
[TD]ECEBGS8625[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ECEOCM50100BB07[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]EPILZ750103[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI3LD22130TK51[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES72151AG400XB0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES72231BL320XB0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES79548LC020AA0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6AV21232DB030AX0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ETMXB4BVB6[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Speciale 175364 BD #LDP 2441 #AVP 4740[/TD]
[TD]Quantita[/TD]
[/TR]
[TR]
[TD]ETMA9F79102[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Speciale 175364 QG #LDP 2439 #AVP 4751
[/TD]
[TD]Quantita
[/TD]
[/TR]
[TR]
[TD]Speciale 175346 QG #LDP 2438 #AVP 4750[/TD]
[TD]Quantita[/TD]
[/TR]
[TR]
[TD]ECEOCM50100BB07[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]EPILZ750103[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI3LD22130TK51[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES72151AG400XB0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES72231BL320XB0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6ES79548LC020AA0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ESI6AV21232DB030AX0[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]ETMXB4BVB6[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Speciale 175364 BD #LDP 2441 #AVP 4740
[/TD]
[TD]Quantita[/TD]
[/TR]
[TR]
[TD]Speciale 175364 QG #LDP 2439 #AVP 4751
[/TD]
[TD]Quantita[/TD]
[/TR]
[TR]
[TD]Speciale 175346 QG #LDP 2438 #AVP 4750
[/TD]
[TD]Quantita
[/TD]
[/TR]
[TR]
[TD]GIA IN ORDINE DA UFFICIO TECNICO - NON SERVE ORDINARE!!![/TD]
[TD][TABLE="width: 61"]
<tbody>[TR]
[TD="class: xl65, width: 61"]Quantita[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try:
Code:
Sub RemoveQuantita()


    Dim arrIn()     As Variant
    Dim x           As Long
    Const Quantita  As String = "Quantita"
    
    x = Cells(Rows.Count, 1).End(xlUp).row
    arrIn = Cells(1, 1).Resize(x, 2).Value
    
    For x = LBound(arrIn, 1) To UBound(arrIn, 1) - 1
        If arr(x, 2) = Quantita Then
            If arr(x + 1, 2) = Quantita Then arr(x, 1) = vbNullString
        End If
    Next x
    
    Application.ScreenUpdating = False
    With Cells(1, 1).Resize(UBound(arr, 1), UBound(arr, 2))
        .Value = arr
        .Offset(, 1).Resize(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    Application.ScreenUpdating = True
    Erase arr
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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