+ Reply to Thread
Results 1 to 6 of 6

Adding Search Function To Delete Matching Records

  1. #1
    Registered User
    Join Date
    04-21-2009
    Location
    Puyallup, WA
    MS-Off Ver
    Excel 2010
    Posts
    55

    Adding Search Function To Delete Matching Records

    Hi,

    I absolutely don't comprehend a VBA search code I picked up somewhere online. I've attached a macro workbook and inside you can type words into cell C16 and search results will populate from columns A & B. That part's great.

    Now, what I'd like to do is click the delete button and when clicked, it will search for matching records in column A & B and if they match... I'm thinking the code for that is <> but I'm not sure, then delete that record, and shift the cells up. Do this until the search results are empty below the delete button.

    Like I said, it's probably more understandable to look at the workbook.

    I'd be very thankful for any help I receive. Also, could someone please explain to me how exactly the search function works exactly>? Piece by piece?

    Thanks

    Please Login or Register  to view this content.
    Also, is there any search code that's easier to understand than this?
    Attached Files Attached Files
    Last edited by sweetrevelation; 06-01-2009 at 09:01 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Adding Search Function To Delete Matching Records

    Do you actually need the intermediate stage? If not, you could just enter the search term and have the code delete the appropriate entries.

  3. #3
    Registered User
    Join Date
    04-21-2009
    Location
    Puyallup, WA
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Adding Search Function To Delete Matching Records

    I need to keep the search functionality separate from the delete functionality. And to answer your question, that's the problem, I don't know how to have the code delete the appropriate entries. That's what my question is. Here's my process.

    I'm using this to search and sort through keywords. Most of the time, I like the keywords I have manually inserted in column B. Every once in a while, I have missed a keyword... for example "eat". I want to delete all records (keywords that have the word "eat" + respective number in column A) and that way "eat" is not in my keyword list. I can continue doing what I'm doing.

    This search part is just a tiny piece of a much larger system.
    Last edited by sweetrevelation; 06-01-2009 at 08:23 AM.

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Adding Search Function To Delete Matching Records

    I understand the question and it's not difficult to add the deletion part. It's pretty much the reverse of the code you already have. See Help for how Instr works.

    Please Login or Register  to view this content.
    Last edited by StephenR; 06-01-2009 at 08:40 AM.

  5. #5
    Registered User
    Join Date
    04-21-2009
    Location
    Puyallup, WA
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Adding Search Function To Delete Matching Records

    That did the trick. I have to hit the button twice for some reason but I can live with that. Thanks for your help. I'm a bloody moron. I wasn't looking at it like it was the reverse. I was looking at it like I didn't want to compromise the search functionality with a different macro. Sorry for the dumb question but thanks for all your help. You really helped me out.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Adding Search Function To Delete Matching Records

    OK, glad it worked. Not sure about the button - did you assign the macro to the button? That might sort it out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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