NKlawender
New Member
- Joined
- Apr 5, 2022
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
I am trying to write a macro that will delete rows based on criteria in two columns. The columns contain written answers to survey questions. I want to delete the rows where both cells are blank, both cells say <Not defined>, both cells say na or n/a, both cells have just a period. Here is what I have written. The issue is that I get an error every time i try to run it, when I hit debug, the part in yellow is what is highlighted. I'm not sure what the issue is. Also, is there another way this could be done that may be faster? There are usually around 35,000 rows of data.
'Delete blank verbatim response rows
Dim LastA As Long
With Sheets("Combined Clean Files")
LastA = .Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For r = LastA To 2 Step -1
If .Cells(r, 11) = "" And .Cells(r, 12) = "" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "." And .Cells(r, 12) = "." Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "na" And .Cells(r, 12) = "na" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "n/a" And .Cells(r, 12) = "n/a" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "<Not defined>" And .Cells(r, 12) = "<Not defined>" Then .Cells(r, "A").EntireRow.Delete
Next r
End With
Application.ScreenUpdating = True
There is a little more to this code, but it is only opening and saving the files.
Thank you,
Norm
'Delete blank verbatim response rows
Dim LastA As Long
With Sheets("Combined Clean Files")
LastA = .Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For r = LastA To 2 Step -1
If .Cells(r, 11) = "" And .Cells(r, 12) = "" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "." And .Cells(r, 12) = "." Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "na" And .Cells(r, 12) = "na" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "n/a" And .Cells(r, 12) = "n/a" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, 11) = "<Not defined>" And .Cells(r, 12) = "<Not defined>" Then .Cells(r, "A").EntireRow.Delete
Next r
End With
Application.ScreenUpdating = True
There is a little more to this code, but it is only opening and saving the files.
Thank you,
Norm