+ Reply to Thread
Results 1 to 9 of 9

Macro to delete worksheet/tab if specific text doesn't exist

  1. #1
    Forum Contributor
    Join Date
    07-18-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    192

    Macro to delete worksheet/tab if specific text doesn't exist

    Hi Friends

    I have report with around 50 tabs in a single workbook. I want to create a macro to delete if specific text doesn't exit in the tab.

    Also, is there any way to delete odd or even tabs from the workbook?

    I really appreciate your help with this.

    Thanks in advance.

    Regards
    Arpan

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    to delete if a specific text doesn't exist:
    Please Login or Register  to view this content.
    to delete ODD:
    Please Login or Register  to view this content.
    Last edited by jewelsharma; 01-06-2016 at 12:38 AM. Reason: typo in code

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Hi Arpan
    What is the specific text exist in all sheets ? Is the specific text fixed in speicifc cell (A1 for example) or it may be diiferent?
    I prefer to attach a sample workbook ..
    Regards
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Great jewelsharma
    Just this line would be
    Please Login or Register  to view this content.
    Another point to avoid the error if all the sheets doesn't have the specific text, there would be at least one sheet in the workbook
    Please Login or Register  to view this content.
    Last edited by YasserKhalil; 01-06-2016 at 12:40 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Nice pick up Yasser.
    Appreciate your reviewing my submission.

  6. #6
    Forum Contributor
    Join Date
    07-18-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    192

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Hi jewelsharma

    Thanks for your reply. The first code doesn't work and second code works fine. The first one gives me the error. When I click Debug, it is highlighting "For Each ws In ThisWorkbook".

    Is there anyway to fix this?

    Thanks a lot for your time and help

    Regards
    Arpan

  7. #7
    Forum Contributor
    Join Date
    07-18-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    192

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Thanks a lot Yasser

    It works perfect now. Appreciate your help. I have updated the code as advised.

    Regards
    Arpan

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Arpan,
    I have just edited by earlier response. In the highlighted line, please replace ThisWorkbook with ThisWorkbook.Worksheets (as spotted by Yasser).
    Let us know if it still doesn't work.

    Cheers!
    Jewel

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to delete worksheet/tab if specific text doesn't exist

    Really nice codes Mr. Jewel
    Thank you very much for this great solutions
    Kind Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 20
    Last Post: 02-11-2015, 04:42 PM
  2. Replies: 0
    Last Post: 02-23-2014, 10:31 PM
  3. How to delete a worksheet if it doesn't exist in a list
    By iamrickdeans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2013, 09:46 AM
  4. VBA to delete row if specific value exist in row above
    By Borg in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-03-2010, 05:49 PM
  5. Insert row if text doesn't exist
    By murzyn1975 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2009, 04:49 AM
  6. Replies: 4
    Last Post: 06-18-2006, 01:10 PM
  7. search for worksheet, insert new if doesn't exist
    By cereldine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2006, 12:15 PM

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