![]() |
Help with activating previous sheet
Hello, I am having trouble making Excel activate the previous workbook. We have a program which automatically creates spreadsheets in Excel (With random names) so I cannot just do a workbook("Book1.xls").activate code. I am looking for a way to say "Go back to the last workbook you were in". Is this possible?? Thanks John C -- johncassell ------------------------------------------------------------------------ johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016 View this thread: http://www.excelforum.com/showthread...hreadid=540647 |
Help with activating previous sheet
If the process is controlled by code you could do something like this:
In header: Public LastBookUsed as Workbook In your sub: Set LastBookUsed = Workbooks.Add .... LastBookUsed.Activate But this would only work in certain situations where your code is in control; if the user freely switches workbooks you need to trap that as an event in order to keep track of which book was last used. The Excel Application has a WorkbookActivate event but I think you would need to create a class With Events in order to trap the event and create an event procedure that would keep track of the last workbook the user was in. -- - K Dales "johncassell" wrote: Hello, I am having trouble making Excel activate the previous workbook. We have a program which automatically creates spreadsheets in Excel (With random names) so I cannot just do a workbook("Book1.xls").activate code. I am looking for a way to say "Go back to the last workbook you were in". Is this possible?? Thanks John C -- johncassell ------------------------------------------------------------------------ johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016 View this thread: http://www.excelforum.com/showthread...hreadid=540647 |
All times are GMT +1. The time now is 12:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com