nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
Hi guys-
I am having some trouble with some code. I run the below code to delete rows if Column B has either D000001 or D00000L8. The code runs, and some of the rows will get deleted, and if i keep running it more and more will delete, but for some reason my code will not run to the bottom and get all of them, this particular sheet has 4108 rows. I did notice that some of the values have a space or even two after them and thought maybe that was the problem?
as always, thank you for any help
I am having some trouble with some code. I run the below code to delete rows if Column B has either D000001 or D00000L8. The code runs, and some of the rows will get deleted, and if i keep running it more and more will delete, but for some reason my code will not run to the bottom and get all of them, this particular sheet has 4108 rows. I did notice that some of the values have a space or even two after them and thought maybe that was the problem?
VBA Code:
Option Compare Text
Dim finalrow As Long
Dim m As Long
Dim t As Long
Dim trim As Long
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For m = 2 To finalrow
If Cells(m, 2).Value = "D0000010" Or Cells(m, 2).Value = "D00000L8" Then
Cells(m, 2).EntireRow.Delete
End If
Next m
End Sub
as always, thank you for any help