Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 7 of 7

Thread: VBA: Closing a worksheet within a macro without saving

  1. #1
    Join Date
    24th June 2003
    Posts
    166
    I have macro within a spreadsheet that opens an other template, this template does some calculations and result is pasted to clipboard. I wish to close this template (without saving) without a dialog box appearing and asking me if I wish to save it.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    18,345
    VB:
    Application.DisplayAlerts = False 
    ActiveWorkbook.Close 
    
    
    This should do it. The first line prevents the warning message, the second closes the workbook
    Last edited by royUK; January 7th, 2006 at 16:17.
    Hope that Helps

    Roy

    For free Excel tools & articles visit my web site

    If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

  3. #3
    Join Date
    28th January 2003
    Location
    Solihull - England
    Posts
    8,678
    VB:
    Sub closernosave() 
        ActiveWorkbook.Close (False) 
    End Sub 
    
    
    hope this helps

    will
    Kind Regards, Will Riley

    Web Presence:
    LinkedIn: Will Riley

  4. #4
    Join Date
    7th January 2006
    Posts
    4

    Re: VBA: Closing a worksheet within a macro without saving

    I am having the same problem but the above code does not work for me, I am still asked to save the file.

    Any other suggestions,
    Thanks in advance,
    Jeff T.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    15th April 2003
    Location
    USA
    Posts
    7,396

    Re: VBA: Closing a worksheet within a macro without saving

    Try the single line (adjusted for name)
    VB:
    Workbooks("Whatever").close False 
    
    
    The False means don't ask, don't save.
    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us will be ignored.

  6. #6
    Join Date
    7th January 2006
    Posts
    4

    Re: VBA: Closing a worksheet within a macro without saving

    Thanks guys for all the help. I save the first time and then close using the false pass parameter.

    Works great,
    Thanks again,
    Jeff
    Last edited by jtrump; January 10th, 2006 at 11:35.

    Excel Video Tutorials / Excel Dashboards Reports


  7. #7
    Join Date
    7th January 2006
    Posts
    4

    Re: VBA: Closing a worksheet within a macro without saving

    Thanks, that works great now.

    Thanks again,
    Jeff

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Saving a Worksheet without the Macro
    By omuhans in forum EXCEL HELP
    Replies: 8
    Last Post: January 6th, 2006, 22:49
  2. Saving and closing
    By William B in forum EXCEL HELP
    Replies: 2
    Last Post: November 22nd, 2005, 03:35
  3. Closing a workbook without saving
    By james_skeggs in forum EXCEL HELP
    Replies: 1
    Last Post: August 4th, 2004, 01:29
  4. Closing workbook(s) without saving [SOLVED]
    By toepoker in forum EXCEL HELP
    Replies: 3
    Last Post: April 23rd, 2003, 10:47

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
  •  
porno