+ Reply to Thread
Results 1 to 12 of 12

Delete Empty Worksheet Modules

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,722

    Delete Empty Worksheet Modules

    I would like to delete all the empty worksheet modules for the active workbook instead of removing these one by one

    it would be appreciated if someone could assist me

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Delete Empty Worksheet Modules


    As a worksheet module can only be deleted by deleting the worksheet itself …

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Delete Empty Worksheet Modules

    This routine will remove Module1 from the current project.
    This code should not be in Module1

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Delete Empty Worksheet Modules


    In the previous post 'Module1' can't be obviously a worksheet module …

  5. #5
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,722

    Re: Delete Empty Worksheet Modules

    Thanks Marc

    module1 is the main module, but by using the macro recorder one could end up with several modules that one no longer requires but one needs to delete these manually one by one

  6. #6
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,722

    Re: Delete Empty Worksheet Modules

    Thanks mickerickson for the code

    I need to remove all blank modules for the activeworkbook, except module1

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Delete Empty Worksheet Modules

    I was just giving the syntax for removing a code module.
    The loop to check code modules is straight-forward.
    As you write that loop, you need to test if your editor has automatically inserted Option Explicit.

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Delete Empty Worksheet Modules

    Quote Originally Posted by Howardc1001 View Post
    but by using the macro recorder
    So it can not be a worksheet module as you wrote 'cause the Macro Recorder uses only regular modules …

  9. #9
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,722

    Re: Delete Empty Worksheet Modules

    thanks guys

    The modules appear as
    Attached Images Attached Images

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Delete Empty Worksheet Modules

    This works - but it's set to delete a module with less than three lines - take care

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  11. #11
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,722

    Re: Delete Empty Worksheet Modules

    Hi xladept


    Thanks , your code works perfectly

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Delete Empty Worksheet Modules

    You're welcome and thanks for the rep!

+ 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] How to delete large number of empty rows in Huge WorkSheet
    By kwiatkowskij32167 in forum Excel General
    Replies: 8
    Last Post: 12-11-2015, 05:37 AM
  2. Macro Button to Delete Entire Row if cells in two columns are empty in certain worksheet
    By Adriana Lee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2015, 07:49 PM
  3. [SOLVED] How to delete empty row at once in a worksheet?
    By Indra Rai in forum Excel General
    Replies: 2
    Last Post: 09-27-2014, 12:19 AM
  4. How to select a worksheet and delete the rows that are 0 or empty on column 3(C)
    By lee478 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2013, 10:44 PM
  5. How do I delete empty macro modules
    By TryToExcel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2010, 05:26 PM
  6. Empty modules
    By damorrison in forum Excel General
    Replies: 1
    Last Post: 03-23-2006, 02:15 PM
  7. [SOLVED] How do I delete an empty worksheet.
    By Jimmy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-03-2005, 02:06 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