Hey guys,
im working on a big amount of data, and my initial step is to clear all the useless rows, what i describe as useless: if cell (M+rowNr) does not start with 25 26 or 27
So my code looks like this:
Sub DataCleanUp()
Dim counter1 As Integer, lastrow As Integer
lastrow = Cells.Find(what:="*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
For counter1 = lastrow To 1 Step -1
If left(Range("M" + CStr(counter1)).Value,2) <> "25" And left(Range("M" + CStr(counter1)).Value,2) <> "26" And left(Range("M" + CStr(counter1)).Value,2) <> "27" Then
Rows(counter1).Delete
End If
Next
End Sub
And its really slow, how can i do this faster?
I can setup a custom sort and after sorting everything make a cutoff right after 27 ends, but maybe there's just a better way to search in vba that i need to learn
im working on a big amount of data, and my initial step is to clear all the useless rows, what i describe as useless: if cell (M+rowNr) does not start with 25 26 or 27
So my code looks like this:
Sub DataCleanUp()
Dim counter1 As Integer, lastrow As Integer
lastrow = Cells.Find(what:="*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
For counter1 = lastrow To 1 Step -1
If left(Range("M" + CStr(counter1)).Value,2) <> "25" And left(Range("M" + CStr(counter1)).Value,2) <> "26" And left(Range("M" + CStr(counter1)).Value,2) <> "27" Then
Rows(counter1).Delete
End If
Next
End Sub
And its really slow, how can i do this faster?
I can setup a custom sort and after sorting everything make a cutoff right after 27 ends, but maybe there's just a better way to search in vba that i need to learn