Macro to automatically close file without the pop-up save ch

Cosmos75

Active Member
Joined
Feb 28, 2002
Messages
359
I have a macro from a spreadsheet (A) that opens up another spreadsheet (B), copies a ranges and pastes it into the A spreadsheet, then closes B.

The thing is, after that it asks if I want to save the changes to B, and then it says there is a large amount of memory on the clip board and if I want it erased (is fo, choose NO). Is there a statement I can add to my macro to automatically choose No to both pop-up messagebox questions?

THANKS!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
On 2002-04-02 12:18, Cosmos75 wrote:
It works. THANKS! One question though, will the clipboard still be cleared?

No ths clipboard will not be cleared so that
if you have a large amount of data held after
the save then you will get a msg prompt to
discard or save it...even with application
enable events.
You shold clear the clipboard if you don't
want this msg prompt.

Application.cutcopymode = false
 
Upvote 0
It works in one workbook and not another! HELP!


Range("A2").Select
Range(Selection, Range("A65536").End(xlUp)).Select
Selection.Copy
ChDir "C:My Documents"
Workbooks.Open Filename:= _
"C:My DocumentsSecond.xls"
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Columns("C:F").Select
Application.CutCopyMode = False
Selection.Copy
'Please make sure that this is the correct spreadsheet
Windows("First.xls").Activate
Columns("D:G").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
Windows("Second.xls").Activate
Application.DisplayAlerts = False
ActiveWindow.Close
This message was edited by Cosmos75 on 2002-04-11 11:17
 
Upvote 0
hi, Cosmos75
Sub cv()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Range(Cells(2, 1), Cells(65536, 1) _
.End(xlUp)).Copy
Workbooks.Open Filename:= _
"C:My DocumentsSecond.xls"
Workbooks("Second.xls").Sheets(1). _
Range("a1").PasteSpecial Paste:=xlValues
Workbooks("Second.xls").Sheets(1). _
Columns("C:F").Copy
Workbooks("First.xls").Sheets(1). _
Columns("D:G").PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
Workbooks("Second.xls").Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

you might want to change a1 to a2 as the destination for the first paste, and also check if you are using sheet 1....
 
Upvote 0
sutjh,

Thanks!!

I never really know which parts of a statement I can take out, like all those extre parts for paste special or pagesetup and things like that. I usually just follow code statement structure that I get from recording a macro.
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,288
Members
448,563
Latest member
MushtaqAli

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