Excel workbook Return

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Hi all, One more question. I have a excel workbook that is linked to anouther excel workbook. When I Hit the Cmd button to go to the other workbook It opens fine, but when I want to end and close the work book it goes to the next (window app) I have open. Anyway to "on closing" to make it go back to the workbook that it is linked to ? Thx Dan
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi Dantb

In the Workbook that is closing place this code in the Private Module of the Workbook, and change Book1.xls to the name of the Workbook you want to activate.

Code:
Option Explicit
Dim bClose As Boolean

Private Sub Workbook_BeforeClose(Cancel As Boolean)
 bClose = Not Cancel
End Sub

Private Sub Workbook_Deactivate()
 On Error Resume Next
  If bClose = True Then Workbooks("Book1.xls").Activate
 On Error GoTo 0
End Sub


_________________
Kind Regards
Dave Hawley
OzGrid Business Applications
Microsoft Excel/VBA Training
OzGrid.BusApp.170x45.gif

This message was edited by Dave Hawley on 2002-04-01 21:25
 
Upvote 0

Forum statistics

Threads
1,214,383
Messages
6,119,196
Members
448,874
Latest member
Lancelots

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top