Hi guys,
I have not posted recently or worked with VBA in some time and am now trying to write this VBA program to transfer a copy of the same profile limits from a static file ("Profile" file) to a series of result files (listed as Gen5 Result files or Destination). I wrote this code but it is giving me a 424 error at the first point I am trying to paste into the destination workbook ("wbDest"). I think that the Paste statement is written incorrectly but not sure.
Thanks for your help.
I have not posted recently or worked with VBA in some time and am now trying to write this VBA program to transfer a copy of the same profile limits from a static file ("Profile" file) to a series of result files (listed as Gen5 Result files or Destination). I wrote this code but it is giving me a 424 error at the first point I am trying to paste into the destination workbook ("wbDest"). I think that the Paste statement is written incorrectly but not sure.
Code:
Sub DAS_Test()
Dim wbDest As Workbook
Dim fDestFileNameAndPath As Variant
'Opens Destination file (Gen5 Results File)
fDestFileNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),*.xls", Title:="Select Gen5 Result File To Be Opened")
If fDestFileNameAndPath = False Then Exit Sub
Set wbDest = Workbooks.Open(fDestFileNameAndPath)
'Opens Profile source File ("**MethodProfile"
Workbooks.Open Filename:="C:\Result Review Profiles\ProreninMethodProfile.xls"
'Copy data from the Profile file------------------------------
Windows("ProreninMethodProfile.xls").Activate
Range("A1:D15").Copy
'Paste into the Lab Result file------------------------
wbDest("Sheet1").Range("M17:P31").PasteSpecial xlPasteAll
'Copy data from Profile file------------------------------
Windows("ProreninMethodProfile.xls").Activate
Range("B19:B93").Select
Application.CutCopyMode = False
Selection.Copy
'Paste into the Lab Result file------------------------
wbDest("Sheet1").Activate
Range("I76:I150").Select
Range("I76:I150").PasteSpecial xlPasteAll
'Close the Profile file without saving it-------------------
Windows("ProreninMethodProfile.xls").Activate
ActiveWindow.Close
'Close the Gen5 Result file, save it, then close it-------------------
Application.CutCopyMode = False
wbDest("Sheet1").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub