user2280549
user2280549

Reputation: 1234

Switch back to one workbook after activating another workbook

My problem is as follows:

I have two files opened - file1.xlsm and file2.xlsm. The first one is active. I want to switch back to the first workbook, every time I activate the second one. I put

Private Sub Workbook_Activate()

    Windows("file1.xlsm").Activate

End Sub

in a macro module of the second workbook. It doesn't work. Is there a way to do it? Thanks for any help

Upvotes: 0

Views: 235

Answers (2)

You have to place

Private Sub Workbook_Activate()
    Workbooks("file1.xlsm").Activate
End Sub

in the ThisWorkbook code window of file2.xlsm (not a macro module).

Upvotes: 1

ttaaoossuu
ttaaoossuu

Reputation: 7884

Try

Call Workbooks("filename.xlsm").Activate

Upvotes: 0

Related Questions