I'm trying to copy a sheet from two identically named workbooks. The only way i can think to do this is to open the file with the sheet to be copied in a separate instance of excel. but i can't get the copy code right. maybe there's a different way to do this altogether
Just a snippet
Just a snippet
Code:
Dim oldWB As Excel.Application
Set oldWB = CreateObject("Excel.Application")
'Make sure the path exists then open
If Dir(prior_path) <> "" Then
Set oldWS = oldWB.Workbooks.Open _
(FileName:=prior_path, ReadOnly:=True)
oldWB.Visible = True
Else
GoTo skip1:
End If
DoEvents
'This is what bugs up.... Assuming i have to activate it or something but it bugs then too
oldWS.Sheets("Copy Sheet").Copy After:=NewWS.Sheets("Sheet 1"), Name:="Copy Sheet"
oldWS.Workbooks.Close
skip1:
Set oldLB = Nothing