Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save erajanraja24/0df819b59301ea67965ee5854dbe86ed to your computer and use it in GitHub Desktop.
Save erajanraja24/0df819b59301ea67965ee5854dbe86ed to your computer and use it in GitHub Desktop.
Excel VBA macro to delete rows based on condition
Sub deleterowsvba()
Dim lrow As Integer, i As Integer
'Determine the last row of column A in sheet 1
lrow = ThisWorkbook.Sheets(1).Range("A65356").End(xlUp).Row
'Find and delete the rows which contain property 2 starting from the last column
For i = lrow To 2 Step -1
If ThisWorkbook.Sheets(1).Cells(i, 2) = 2 Then
ThisWorkbook.Sheets(1).Rows(i).EntireRow.Delete
End If
Next i
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment