+ Reply to Thread
Results 1 to 5 of 5

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

  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;

    Please Login or Register  to view this content.
    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;

    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

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

    Hi

    This type of problem is quite common and I see it all the time. The approach I adopt almost invariably is as follows.

    1. Do the Text to Columns first.
    2. Give yourself some working room by adding three or four helper columns A-C
    3. Now work out some helper formulae which identify whether a particular row should be deleted or not. The aim being to eventually identify just the rows you don't want e.g. in A1

    Please Login or Register  to view this content.
    depending on your data it may be necessary to build this up with AND functions which examine other columns, and if it starts to get complicated just use the other helper columns to break the testing down. Once you've got the formula right, copy it down your whole list and filter column A for the word "Delete" and then just select and delete the filtered rows.

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

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

    hmmm, so my next question is... is there way to index it so that it can search and goto the first instance of the "Keep" cell. That way it doesnt have to go through every single cell. If I can do that, then it would improve the speed of the process.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

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

    If you're examining column A and deleting all the rows that DON'T have a number in column A, but have text of somekind instead, try this:

    Please Login or Register  to view this content.

    If there are blanks to deal with, too:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

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

    Ok so I finally figured it out!! pretty much used your formula in VBA to code the cells in column E, then used excel internal search function to find the first instance, and delete all above, and the last instance ect....

    Worked PERFECTLY!!


    Thanx for all the help

+ Reply to Thread

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