I am trying to delete records where column 18 = "000000" and column 20 = "000000
I am using the following macro I copied from the web
Dim r As Long
Application.ScreenUpdating = False
For r = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If Cells(r, 18) = "000000" And Cells(r, 20) = "000000" Then Rows(r).Delete
Next r
Application.ScreenUpdating = True
End Sub
I have been told that there is a better way to loop it because the method above would stop if there happen to be blank rows. (Which should never be the case.)
The problem is that this macro is deleting more than the 7 rows it should be deleting. Any idea on a fix?
*note This is actually a small part of a very large project. Really what I would like to do is Cut/Paste these records to a new sheet in the workbook called deleted. After I do that then I need to Cut/Paste duplicates into the same sheet called deleted"
1.) I am cutting and pasting the rows with "000000" in the 2 cells because they are actually copies (but not really copies) of records that exist with the proper numbers in those fields. So I want to remove all the rows where
a) Column 1 exists twice
b)And Column 18 and 20 both equal "000000"
2.) Cut and Paste Duplicates into a sheet because I am getting records that have Identical records for every field.
3.) By putting these into another sheet(s) I can check to make sure it is working properly.
4.) I want this to make it as auto as possible once set up. This spread sheet is created by exporting a large query (25k records returned) from an even larger database. So I export the results from Access and then I am manually performing this. Eventually the goal is to roll all of this up in a powershell program that will do it all. My limited knowledge will put that off for a while.
All Help very appreciated!!
Bookmarks