Hello,
well I am not an expert, but maybe this would be some start
Sub Jedziemy_Z_Koksiorem()
Dim a As Long
a = Range("A65000").End(xlUp).Row
'first need to sort this data
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("INPUT").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("INPUT").Sort.SortFields.Add Key:=Range("A2:A" & a), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("INPUT").Sort
.SetRange Range("A1:D" & a)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'next check on all data for delete
For Each cell In Range("A2:A" & a)
If cell.Value = cell.Offset(1, 0).Value Then
If cell.Offset(0, 1).Value + cell.Offset(1, 1).Value = 0 Then cell.Offset(0, 4) = "y"
End If
Next cell
For Each cell In Range("A2:A" & a)
If cell.Value = cell.Offset(-1, 0).Value Then
If cell.Offset(0, 1).Value + cell.Offset(-1, 1).Value = 0 Then cell.Offset(0, 4) = "y"
End If
Next cell
For Each cell In Range("B1:B" & a)
If cell.Value <= 0 Then cell.Offset(0, 3) = "y"
Next cell
'now it's delete code
For i = Cells(Rows.Count, "E").End(xlUp).Row To 2 Step -1
If Cells(i, "E").Value = "y" Then
Rows(i).Delete shift:=xlUp
End If
Next
End Sub
Bookmarks