+ Reply to Thread
Results 1 to 14 of 14

Delete same sheets across all opende workbooks

  1. #1
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Delete same sheets across all opende workbooks

    Hi,

    I have lots of workbooks, approximately 50, with the same range of sheets... well, some sheets may have a little bit more sheets, but it does not matter, the main thing is that, all of them include several sheets, which have same names across all workbooks.

    Could you please, provide with the public code which will enable me to run it as add-in or public macro, and enable me to delete indicated sheets accross all workbooks at once.


    Any help will be appreciated, thank yoo in advance.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Delete same sheets across all opende workbooks

    assuming all the files in the same folder?

    run macro to read thru all excel files and delete any sheet named "whatever it is"
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256
    Yes. All the workbook can be located in the same directory. And I need to delete sheets in each workbook., but with indicated names, as each workbook contains sheets with same names, so I need to delete only some of them in each workbook.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Delete same sheets across all opende workbooks

    how do you determine in which workbook which sheet requires deleting?

  5. #5
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Re: Delete same sheets across all opende workbooks

    I know their names, for example "sales", "ITM Report" and so on... for exmaple each workbook has 20 sheets, but I need to delete the sheets which will have the indicated names, for example "sales", "ITM Report" etc. Because each workbook have sheets with name names, well may be some of them may include extra sheet, but any way I will need to delete predefined sheets.

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Delete same sheets across all opende workbooks

    Please Login or Register  to view this content.
    this code will run thru a set directory and open anything with .xls (including xlsx)
    can you amend the IF section to you needs

    PLEASE make backup of directory first and use temp!! before going "live"
    Last edited by humdingaling; 08-23-2013 at 03:16 AM. Reason: Disclaimer =)

  7. #7
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Re: Delete same sheets across all opende workbooks

    How can I include directory there??

    my direcotry of workbooks is in my case: C:\Users\cstbregvg\Desktop\Sales reports\xls

  8. #8
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Re: Delete same sheets across all opende workbooks

    Works perfectly, thanks...

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Delete same sheets across all opende workbooks

    Please Login or Register  to view this content.
    as mentioned above in post #6, amend the if section to determine what sheet you delete
    currently it just gives you non destructive msgbox
    if you put delete code in there the action is irreversible

  10. #10
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256
    Yes. I understand, I listed there all the sheet names and it only finds them..

  11. #11
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Delete same sheets across all opende workbooks

    the code for deleting worksheets is

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256
    Thank you very much. You helped me a lot. Thank you again exactly what was needed.

  13. #13
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Delete same sheets across all opende workbooks

    havent tested it but i think you may need a workbook save to stop warning message when you close workbooks
    if so
    .save
    .close

  14. #14
    Forum Contributor G.Bregvadze's Avatar
    Join Date
    12-06-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010 - 2016
    Posts
    256

    Re: Delete same sheets across all opende workbooks

    Thank you for the support, I did the same, and it works perfectly, thanks a lot...
    Last edited by G.Bregvadze; 08-23-2013 at 03:24 PM.

+ 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: 2
    Last Post: 11-29-2012, 04:56 AM
  2. Replies: 0
    Last Post: 11-29-2012, 04:50 AM
  3. [SOLVED] Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 08:12 PM
  4. Replies: 0
    Last Post: 06-21-2005, 01:05 PM
  5. [SOLVED] Re: Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2005, 01:05 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