Closing a File w/out Saving

Littlemalky

Board Regular
Joined
Jan 14, 2011
Messages
223
I'm not exactly sure what's wrong with my code. From what I can tell this is how I'm suppose to format the code, yet it stops at the "ActiveWorkbook.Close False" line and doesn't register. Anybody have any ideas?
Code:
Sub CopyCells()
    Workbooks("PRE-RELEASE.xlsx").Worksheets("Sheet1").Activate
    Cells.Select
    Selection.Copy
    Workbooks("PRE RELEASE SHEET " & Format(Date, "m.dd.yy") & ".xlsx").Worksheets("RELEASE").Activate
    Cells.Select
    ActiveSheet.Paste
    Range("A1").Select 'Resets starting point, and deselects worksheet
    Workbooks("PRE-RELEASE.xlsx").Activate
    [COLOR=red]ActiveWorkbook.Close False[/COLOR] 'Closes without saving changes
    Application.CutCopyMode = False 'Clears the clipboard
    'Application.Run ThisWorkbook.Name & "!" & "PreRelease_Bom_Scrub.PartsList" 'Signals next macro
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try:

Code:
Sub CopyCells()
    Workbooks("PRE-RELEASE.xlsx").Worksheets("Sheet1").Cells.Copy _
        Destination:=Workbooks("PRE RELEASE SHEET " & Format(Date, "m.dd.yy") & ".xlsx").Worksheets("RELEASE").Range("A1")
    Workbooks("PRE-RELEASE.xlsx").Close SaveChanges:=False 'Closes without saving changes
    'Application.Run ThisWorkbook.Name & "!" & "PreRelease_Bom_Scrub.PartsList" 'Signals next macro
End Sub
 
Upvote 0
Thank you, that worked perfectly, and it shows how inexperienced I am because your code is so much more efficient.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top