+ Reply to Thread
Results 1 to 5 of 5

Want to delete every worksheet that *doesn't* contain one of several phrases

  1. #1
    Registered User
    Join Date
    07-07-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Want to delete every worksheet that *doesn't* contain one of several phrases

    Hi all,

    I've got a problem that I've had trouble finding a solution for using Google-Fu.

    In short, I want to have a macro or otherwise automatable solution that deletes a worksheet if it doesn't contain either Phrase A, Phrase B, Phrase C, or Phrase D. (any of the four phrases will do.)

    Can VBA do this?

    Since I use a lot of ASAP Utilities and AutoHotKey, I can automate the 'outer shell' pretty easily if I can figure out the most basic step: How do I have Excel check whether or not a cell contains a given line of text?

    Ideally, this would simply be an '=IF' statement. But I can't seem to put one together that answers this.


    Or could I filter sheets based on whether or not they have one of the phrases, and then copy only the sheets still displayed?


    Not sure how to go about handling this.
    Last edited by Televangelist; 07-08-2011 at 11:31 AM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Want to delete every worksheet that *doesn't* contain one of several phrases

    Televangelist,

    Welcome to the Excel Forum.


    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

    To attach your workbook, click on the New Post button, then scroll down and click on the Go Advanced button, then scroll down and click on the Manage Attachments button.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Want to delete every worksheet that *doesn't* contain one of several phrases

    Please Login or Register  to view this content.



  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Want to delete every worksheet that *doesn't* contain one of several phrases

    I'm only posting this because I've been working on this for a little while. Also, I couldn't finesse it quite like snb's so I changed the Phrase A to Phrase1 and so on.
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  5. #5
    Registered User
    Join Date
    07-07-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Want to delete every worksheet that *doesn't* contain one of several phrases

    Thanks for the help, guys!

+ 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