Error with code to delete rows based on cell contents

NKlawender

New Member
Joined
Apr 5, 2022
Messages
21
Office Version
  1. 365
Platform
  1. Windows
I ran this code lasst month and it worked perfectly, now this month, it is giving me an error. I have no idea why. Any ideas?
Dim LastA As Long
With Sheets("Sheet1")
LastA = .Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For r = LastA To 2 Step -1
If .Cells(r, "S") = "<Not defined>" And Cells(r, "T") = "<Not defined>" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, "S") = "." And Cells(r, "T") = "." Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, "S") = "na" And Cells(r, "T") = "na" Then .Cells(r, "A").EntireRow.Delete
If .Cells(r, "S") = "n/a" And Cells(r, "T") = "n/a" Then .Cells(r, "A").EntireRow.Delete
Next r
End With
Application.ScreenUpdating = True

The red part is what is highlighted when I hit Debug.
Thanks,
Norm
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
There's a missing period after the AND

If .Cells(r, "S") = "<Not defined>" And .Cells(r, "T") = "<Not defined>" Then .Cells(r, "A").EntireRow.Delete
 
Upvote 0
Solution
I added the missing periods, but I still get the same error. I ran the exact same code on a smaller (number of rows) spreadsheet and it worked fine. On the larger one, approximately 35000 rows, it gets about a third of the way and then gives me the mismatch (type 13) error. I have no idea why.
Thanks,
Norm
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top