+ Reply to Thread
Results 1 to 2 of 2

Macro to delete sheets and saves remaining file does not properly delete module

  1. #1
    pherrero
    Guest

    Macro to delete sheets and saves remaining file does not properly delete module


    I have a macro that has the user save the file through a command button
    rather than the regular save. This macro checks for data entry errors,
    deletes sheets that were not selected for data entry, and saves the
    remaining file.

    However, the sheet module from the deleted sheets does not get deleted
    (when I say delete, I do not mean that I want the code in the module to
    be blanked; I mean that the module should no longer appear in VBE just
    as the sheet does not appear in the Excel interface).

    Simplified code:

    Private Sub deleteandsave()
    Sheet1.Delete
    ThisWorkbook.Save
    End Sub

    If you look at VBE after running this, the sheet module for Sheet1 does
    indeed get deleted. However, the file that was actually saved maintains
    the sheet module although the worksheet itself was deleted. This in
    effect produces a file with a sheet module that is linked to the
    "ether". This unlinked sheet module can have strange behavior on the
    rest of the file even if blank.

    Any suggestions that makes sure that the module gets deleted before the
    save command is run? (I prefer that Save is not a separate action - If
    you delete sheets and then Save as two independent actions - two
    buttons - the unlinked sheet module does not occur)


    --
    pherreroPosted from http://www.pcreview.co.uk/ newsgroup access


  2. #2
    Registered User
    Join Date
    06-21-2005
    Posts
    19
    Your code works for me

    Gaz
    2B OR NOT 2B, that is FF

+ 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