+ Reply to Thread
Results 1 to 5 of 5

Delete workbook if contains x string

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Delete workbook if contains x string

    Hi,

    I have a large data file which i split into 400 different workbook in a single file. However, some workbook dontains the string:
    NO DATA FOR REPORTING PERIOD

    I want the VBA to find thru all the workbook, and if string "NO DATA FOR REPORTING PERIOD" found, then delete that workbook.

    Thanks

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Delete workbook if contains x string

    Hello calvinle,

    Are you really reffering to 400 Workbooks, or actually 400 different Sheets?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Delete workbook if contains x string

    I have 1 excel file with 400 different sheet inside. Or I can split that excel into separate excel file and run the macro? Which one will be easier?

  4. #4
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Delete workbook if contains x string

    Hi -

    How about this one?
    For Each sht In Sheets
        If Not sht.UsedRange.Find("NO DATA FOR REPORTING PERIOD", , , 1) Is Nothing Then
            Application.DisplayAlerts = False
                sht.Delete
            Application.DisplayAlerts = True
        End If
    Next
    event

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Delete workbook if contains x string

    Incredible!!!! Works awesome!

+ 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. [SOLVED] delete workbook from one location and save workbook to new locatio
    By Damien in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2006, 10:40 AM
  2. [SOLVED] How to Delete a Range in Closed Workbook (to Replace Delete Query)
    By resant_v@yahoo.com in forum Excel General
    Replies: 1
    Last Post: 03-08-2006, 06:10 AM
  3. how to delete a string from another string
    By Ribap in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2006, 06:50 AM
  4. Delete value in a string
    By Todd Huttenstine in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2006, 03:35 PM
  5. re: Automatically Delete WorkBook 2 modules by using Workbook 1 module
    By ddiicc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-27-2005, 08:05 AM

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