Good day to all!
i am using Excel 2007, Windows XP.
trying to write a macros, that determines the range with data in file1 sheet1, copies it and adds it to determined position in sheet1 in file2.
i end up receiving run-time error 1004 on the line i marked with red. any help will be greatly appreciated, as im clueless after trying to make it work trough copy/destination and value methods. below is the latest version of my disaster
Thank you.
i am using Excel 2007, Windows XP.
trying to write a macros, that determines the range with data in file1 sheet1, copies it and adds it to determined position in sheet1 in file2.
i end up receiving run-time error 1004 on the line i marked with red. any help will be greatly appreciated, as im clueless after trying to make it work trough copy/destination and value methods. below is the latest version of my disaster
Thank you.
Code:
Sub COPYCELL()
Dim wbk As Workbook
Dim bgn As String
Dim rght As String
Dim wbk2 As Workbook
strFirstFile = "C:\playground\files playground\file1.xlsx"
strSecondFile = "C:\playground\files playground\file2.xlsx"
Set wbk = Workbooks.Open(strFirstFile)
wbk.Sheets("Sheet1").Range("A65000").End(xlUp).Select
bgn = ActiveCell.Row
wbk.Sheets("Sheet1").Range("IV1").End(xlToLeft).Select
rght = ActiveCell.Column
[COLOR=Red]Workbooks(strFirstFile).Sheets("Sheet1").Range(Cells(1, 1), Cells(bgn, rght)).Copy [/COLOR]
Set wbk2 = Workbooks.Open(strSecondFile)
With wbk2.Sheets("Sheet1")
.Range("A2").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End With
End Sub