Morning All,
Well I am kind of stumped. Pretty much im building a macro that will sort/delete unnecessary rows from a sheet. I work with a "ANCIENT" / OLD database system that pulls records in single rows and very cluttered, so what I do (MANUALLY) is I filter the rows from A to Z, delete about the first 20,000 rows, and the last about 20,000 rows then do a text to column to sort the different information. I say "about" because it ranges everytime I pull from the database we use.
Here is the problem, because the amount of rows above and bellow ranges; the only way to identify where the first row should start is by doing a criteria test. In excel I can use this;
=ISNUMBER(VALUE(MID(LEFT(A40285,4),1,1)))
As you probably figured by now, I deal with CC account numbers which is why I can't upload the workbook.
Here is what I have so far that attempts to search for the criteria, then delete if it doesnt match;
Sub delCells()
Dim intRow
Dim intLastRow
intLastRow = Range("A1048576").End(xlUp).Row
For intRow = intLastRow To 1 Step -1
Rows(intRow).Select
If Not IsNumeric(Left((Cells(intRow, 1).Value), 3)) Then
Cells(intRow, 1).Select
Selection.EntireRow.Delete
Else
Cells(intRow, 1).Select
End If
Next intRow
Range("A1").Select
MsgBox "Your Cells have been sorted and deleted!"
End Sub
This code kind of works.... Only problem is sometimes I work with sheets that have 60,000 rows and for that macro to run would take hours! How do I have the macro search and find the first instance of that criteria of an account number and delete all rows above that, then find the last instance of that criteria and delete all the rows below that?
Any advice is greatly appreciated! Thank you
Bookmarks