Return to Original File

S

Stephen

Hi peoples

I need to make an adjustment to my code. If it opens the file DATA.xl
it needs to return to the original file (that was already open). Th
original file is different every month.

Dim wbk As Workbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
Exit Sub
End If


Regards

Stephe
 
F

Frank Kabel

Hi
try
Dim wbk As Workbook
Dim old_book as workbook
set old_book=activeworkbook
On Error Resume Next
Set wbk = Workbooks("DATA.xls")
On Error GoTo 0
If wbk Is Nothing Then
Workbooks.Open Filename:= _
"C:\DATA.xls"
old_book.activate
Exit Sub
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top