filmov
tv
Excel VBA Macro: Delete Rows Based on Cell Value (Zeros and Blanks)
Показать описание
Excel VBA Macro: Delete Rows Based on Cell Value (Zeros and Blanks). We create a macro that deletes rows based on cell value with specific text. If you ever need to remove all rows that contain a specific value in an excel worksheet, you can use this code to remove those rows.
In this example, we delete rows that contain zeros and delete blank rows specifically. The code searches for a specific value in a designated column, then deletes that entire row if it contains the value you want deleted. The macro counts the number of total rows in the data-set, then goes down each row searching for the specific value in order to delete the entire row, until it reaches the bottom of the range.
Need help opening the VBA editor?
Code:
Sub delete_zeros()
Dim count As Long
Dim i As Long
'msgbox count
i = 1
Do While i <= count
If Cells(i, 7) = 0 Then
Rows(i).EntireRow.Delete
i = i - 1
End If
i = i + 1
Loop
End Sub
#ExcelVBA #ExcelMacro
In this example, we delete rows that contain zeros and delete blank rows specifically. The code searches for a specific value in a designated column, then deletes that entire row if it contains the value you want deleted. The macro counts the number of total rows in the data-set, then goes down each row searching for the specific value in order to delete the entire row, until it reaches the bottom of the range.
Need help opening the VBA editor?
Code:
Sub delete_zeros()
Dim count As Long
Dim i As Long
'msgbox count
i = 1
Do While i <= count
If Cells(i, 7) = 0 Then
Rows(i).EntireRow.Delete
i = i - 1
End If
i = i + 1
Loop
End Sub
#ExcelVBA #ExcelMacro
Комментарии