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
Speciale 175377.2 QG #LDP 2443 #AVP 4748Quantita
ECEPI4431
EPILZ7501031
ESI6AV21232DB030AX01
ESI6ES72151AG400XB01
ESI6ES72231BL320XB02
ESI6ES79548LC020AA01
EDATTHQQS001
Speciale 175427 QG #LDP 2442 #AVP 4726Quantita
ECEBGS86251
ECEOCM50100BB071
EPILZ7501031
ESI3LD22130TK511
ESI6ES72151AG400XB01
ESI6ES72231BL320XB01
ESI6ES79548LC020AA01
ESI6AV21232DB030AX01
ETMXB4BVB61
Speciale 175364 BD #LDP 2441 #AVP 4740Quantita
ETMA9F791021
Speciale 175364 QG #LDP 2439 #AVP 4751
Quantita
Speciale 175346 QG #LDP 2438 #AVP 4750Quantita
ECEOCM50100BB071
EPILZ7501031
ESI3LD22130TK511
ESI6ES72151AG400XB01
ESI6ES72231BL320XB01
ESI6ES79548LC020AA01
ESI6AV21232DB030AX01
ETMXB4BVB61
Speciale 175364 BD #LDP 2441 #AVP 4740
Quantita
Speciale 175364 QG #LDP 2439 #AVP 4751
Quantita
Speciale 175346 QG #LDP 2438 #AVP 4750
Quantita
GIA IN ORDINE DA UFFICIO TECNICO - NON SERVE ORDINARE!!!
Quantita

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

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