+ Reply to Thread
Results 1 to 9 of 9

Delete data upon closing workbook

  1. #1
    Registered User
    Join Date
    05-29-2009
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    78

    Delete data upon closing workbook

    Hi
    is there a macro i can use to delete all data in the 'Serial Nš' cells on all the RED tabbed worksheets when the close button is clicked to close the worklbook?
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Delete data upon closing workbook

    A macro could be written, bu are the cells in the same range in each sheet?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    05-29-2009
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Delete data upon closing workbook

    Yes they are all in H7

  4. #4
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Delete data upon closing workbook

    Pasting this code in "ThisWorbook" object should do it.
    I am deleting from all sheets whose name starts with "S". You may want to change the if condition to check for tab color.

    Please Login or Register  to view this content.
    hth
    Ajay

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Delete data upon closing workbook

    This checks the Tab colour & deletes H7 in the tabs that match the rquirement
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-29-2009
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Delete data upon closing workbook

    Thanks but neither of them seem to work

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Delete data upon closing workbook

    Mine works in the example workbook that you posted. attach the workbook with the code in

  8. #8
    Registered User
    Join Date
    05-29-2009
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Delete data upon closing workbook

    HI
    i have attached the document as requested...
    Attached Files Attached Files

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Delete data upon closing workbook

    You've pasted the code in the wrong place. the code is WorkBook_event code & should be in the workbook module, not a Standard Module
    Attached Files Attached Files

+ 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