Im trying to copy from one workbook to another. But I can't use workbook.name becuase the names keep changing. So to bypass that i created this and It almost works.
Sub Test()
Dim MR As Workbook
Dim Drun As Workbook
Dim myFileName As Variant
Dim SCR As Range, TGT As Range
Dim Inventory As Worksheet
Set Drun = ActiveWorkbook
myFileName = Application.GetOpenFilename
If myFileName = False Then
Exit Sub 'user hit cancel
End If
Set MR = Workbooks.Open(Filename:=myFileName)
Drun.Activate
Sheet3.Select
Range("A4:k20").Copy
MR.Activate
Worksheets("Inventory").Select
Range("a3").Paste <--- Runtime Error 438. Object does support this property
How can I optimize and fix this coding?
Sub Test()
Dim MR As Workbook
Dim Drun As Workbook
Dim myFileName As Variant
Dim SCR As Range, TGT As Range
Dim Inventory As Worksheet
Set Drun = ActiveWorkbook
myFileName = Application.GetOpenFilename
If myFileName = False Then
Exit Sub 'user hit cancel
End If
Set MR = Workbooks.Open(Filename:=myFileName)
Drun.Activate
Sheet3.Select
Range("A4:k20").Copy
MR.Activate
Worksheets("Inventory").Select
Range("a3").Paste <--- Runtime Error 438. Object does support this property
How can I optimize and fix this coding?
Last edited: