jag108
Active Member
- Joined
- May 14, 2002
- Messages
- 433
- Office Version
- 365
- 2016
- Platform
- Windows
- MacOS
Hi Guys my search could not find anything that covers the issue I am having.
Trying to copy a range from one work book (source 2003) to a new worksheet in an Excel 2007 workbook although this work book is still an xls format workbook. I originally was copying the sheet but because there is a difference in version for obvious reasons this failed, so I adjusted my code to use ranges, but now I am getting error 1004, not matter what I try.
First attempt -
second attempt -
But no matter what I do I get error 1004.
Thanks in advance
Trying to copy a range from one work book (source 2003) to a new worksheet in an Excel 2007 workbook although this work book is still an xls format workbook. I originally was copying the sheet but because there is a difference in version for obvious reasons this failed, so I adjusted my code to use ranges, but now I am getting error 1004, not matter what I try.
First attempt -
Code:
Set src_bk = ActiveWorkbook
Set src_sht = ActiveSheet
Set dst_bk = Workbooks("Destination.xls")
If ActiveWorkbook.Name <> dst_bk.Name Then dst_bk.Activate
Set dst_sht = Worksheets.Add
dst_sht.Name = "Destination - " & Format(Now(), "mmm dd")
src_bk.Activate
With src_sht
lrow = .Cells(.Rows.Count, "A").End(xlUp).Row
lcol = .Cells(9, .Columns.Count).End(xlToLeft).Column
End With
Set src_rng = Workbooks(src_bk.Name).Worksheets(src_sht.Name).Range(Cells(1, lrow), Cells(lrow, lcol))
Set dst_rng = Workbooks("Destination.xls").Worksheets(dst_sht.Name).Range("A1")
src_rng.Copy dst_rng
src_bk.Close
second attempt -
Code:
Set src_rng = Range(Cells(1, lrow), Cells(lrow, lcol))
src_rng.Select
Selection.Copy
Workbooks("Destination.xls").Activate
dst_sht.Activate
Range("A1").Select
ActiveSheet.Paste
ActiveWindow.Close
But no matter what I do I get error 1004.
Thanks in advance
Last edited by a moderator: