Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro that closes a worksheet in excel and I want to close it and
not save (usually a box appears asking if I want to save before exiting and I want to say no in the macro) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In the before close event add
ThisWorkbook.Saved = True This is the flag that Excel uses to determine if the file needs to be saved and the code above say that the file does not need to be saved. Don't place any code after this line as that could change the spreadsheet and flip the flag back again. -- HTH... Jim Thomlinson "Brian" wrote: I have a macro that closes a worksheet in excel and I want to close it and not save (usually a box appears asking if I want to save before exiting and I want to say no in the macro) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Brian,
you can use: Worksheets("yourworksheets").close Savechanges:= false This is best way to do it, and never ask you about save changes. "Brian" escreveu: I have a macro that closes a worksheet in excel and I want to close it and not save (usually a box appears asking if I want to save before exiting and I want to say no in the macro) |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Your code does not work. Close is not a method of the worksheets object. It
is a method of the workbook. You could use Thisworkbook.Close SaveChanges:=False but it requires that the user close the workbook via a command button or such to execute this line of code. If the user closes the workbook via the x then this code never executes and the user is prompted about saving... -- HTH... Jim Thomlinson "Renato M. T." wrote: Hi Brian, you can use: Worksheets("yourworksheets").close Savechanges:= false This is best way to do it, and never ask you about save changes. "Brian" escreveu: I have a macro that closes a worksheet in excel and I want to close it and not save (usually a box appears asking if I want to save before exiting and I want to say no in the macro) |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro that closes a worksheet
If it's a worksheet, and not a workbook, perhaps... Sub Demo() Application.DisplayAlerts = False Worksheets(1).Delete Application.DisplayAlerts = True End Sub -- HTH :) Dana DeLouis Windows XP & Office 2003 "Brian" wrote in message ... I have a macro that closes a worksheet in excel and I want to close it and not save (usually a box appears asking if I want to save before exiting and I want to say no in the macro) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Exit a worksheet with out saving changes | Excel Discussion (Misc queries) | |||
Exit with out saving | Excel Programming | |||
Exit via macro only? | Excel Discussion (Misc queries) | |||
on exit macro | Excel Discussion (Misc queries) | |||
Saving Procdb.xla on exit from Excel | Excel Programming |