Deleting records from Excel with macro

Occasional Contributor

I'm new to VBAs and macros. I'm trying to create my first macro and need some help. I'm trying to delete records from an Excel file: all the records that, i.e., the number '1601200-40' in the first column of my Excel should be deleted. I put in the following code but, unfortunately, the macro is only deleting a few of the records that have the value, not all. How do I fix this?


My current code:


Set MR = Range("A1:A3000")
For Each cell In MR
If cell.Value = "1601200-040" Then cell.EntireRow.Delete


0 Replies