Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't Save macro

Tags:

excel

vba

I need to open and close a file using a macro, but I don't want to save it. I can get to wear excel prompts you to Save or Don't save, what is the VBA command for dont save. This is what I am using I just need it to not save and close excel all the way.

Sheets("Sheet1").Select
Range("A1").Select

Sheets("Sheet6").Select
Range("A1").Select

Workbooks.Open Filename:= _
    "X:\File.xlsx"
Workbooks.Close
like image 795
Trying_hard Avatar asked Dec 05 '22 15:12

Trying_hard


1 Answers

Place False in first argument after Close method to tell VBA to not save the Workbook changes. So:

Workbooks.Close False

or

Workbooks.Close SaveChanges:=False
like image 104
Scott Holtzman Avatar answered Dec 14 '22 04:12

Scott Holtzman