Results 1 to 5 of 5

Advance Search and GoTo a cell that meets a certain search criteria

Threaded View

  1. #1
    Registered User
    Join Date
    09-21-2010
    Location
    Brea, CA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Advance Search and GoTo a cell that meets a certain search criteria

    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
    Last edited by moatik; 09-21-2010 at 04:02 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1