Excel VBA Macro: Delete Rows (Based on Cell Values in Multiple Columns)

Опубликовано: 18 Сентябрь 2024
на канале: greggowaffles
3k
36

Excel VBA Macro: Delete Rows (Based on Cell Values in Multiple Columns)

Subscribe:

Code:
Sub delete_rows_based_on_multi_col()

Dim row_count As Long
Dim i As Long
Dim ws As Worksheet

Set ws = ThisWorkbook.Sheets("Countries")

ws.Activate
row_count = ws.Cells(Rows.count, "A").End(xlUp).Row

i = 2

Do While i <= row_count

If Cells(i, 6) = "" _
Or Cells(i, 10) = "" _
Or Cells(i, 5) > 10000 Then

Rows(i).EntireRow.Delete
i = i - 1
row_count = row_count - 1
End If

i = i + 1

Loop

End Sub