I have a main workbook that extracts data from other workbook sheets, then closes the modified workbook suppressing the save option.
other_wb.Close Savechanges = False
However when running the macro or stepping through this function call in DEBUG mode it still saves the file. Is there an alternative way to close without saving? Is there any explanation for this behavior?
I can provide more info if needed.
Savechanges
is an undefined variable. It is thereforeEmpty
;Empty
is falsy, so the expressionSavechanges = False
evaluates toTrue
, so the call becomesother_wb.Close True
, which saves the file.You are missing the colon:
Put
Option Explicit
on top of all your code modules to never have to deal with this kind of issues.