Copy data from open workbook into the close workbook.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Code:
 Range("A1:D20").Select
    Selection.Copy
    Workbooks.Open Filename:="D:\....\.....\0600.xls"
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    ActiveWorkbook.Save
    ActiveWindow.Close

Good Day,
Could someone help me on that captioned code?
When i run that code i don't want to lost the previous datas from close workbook.I just want the code will simply continiously copy the datas all the way down like
Code:
.End(xlUp).Row + 1
everytime run the code.

Many Thanks
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try:

Code:
Range("A1:D20").Copy
    Workbooks.Open Filename:="D:\....\.....\0600.xls"
    Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Paste
    ActiveWorkbook.Save
    ActiveWindow.Close
 
Upvote 0
Sorry Mate but it does give error on the code
Code:
  Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Paste
and run time error is 438
Any idea about that?
 
Upvote 0
Sorry Mate but it does give error on the code
Code:
  Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Paste
and run time error is 438
Any idea about that?

Does it give you any other dialogue along with the run time error?
 
Upvote 0
Hmm - paste can be finicky sometimes:

Code:
Dim LR As Long
Range("A1:D20").Copy
    Workbooks.Open Filename:="D:\....\.....\0600.xls"
    LR = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("A" & LR + 1).Paste
    ActiveWorkbook.Save
    ActiveWindow.Close

if that doesn't work, try:

Code:
Dim LR As Long
Range("A1:D20").Copy
    Workbooks.Open Filename:="D:\....\.....\0600.xls"
    LR = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("A" & LR + 1).PasteSpecial
    ActiveWorkbook.Save
    ActiveWindow.Close
 
Upvote 0
Hmm - paste can be finicky sometimes:

Code:
Dim LR As Long
Range("A1:D20").Copy
    Workbooks.Open Filename:="D:\....\.....\0600.xls"
    LR = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("A" & LR + 1).Paste
    ActiveWorkbook.Save
    ActiveWindow.Close

if that doesn't work, try:

Code:
Dim LR As Long
Range("A1:D20").Copy
    Workbooks.Open Filename:="D:\....\.....\0600.xls"
    LR = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("A" & LR + 1).PasteSpecial
    ActiveWorkbook.Save
    ActiveWindow.Close


MrKowz,
Good Day,
Could you help me on your code?
The ranges has been changed to (A1:D52) and the closed workbook is now hiding file due to prevent to access.
Is it possible to alter the code?
Many Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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