![]() |
Macro switch between windows question
Hi, I have a macro that is flipping between two windows. I recorded it and I'm running into an error. The sheet I was playing around with and recorded it on was called Book1. The macro will be run on sheets with different names. The debugger is highlighting this line: Windows("Book1.xls").Activate How do I make windows go the other open workbook no matter what the name is? Thanks Eddie -- punter ------------------------------------------------------------------------ punter's Profile: http://www.excelforum.com/member.php...fo&userid=2044 View this thread: http://www.excelforum.com/showthread...hreadid=554196 |
Macro switch between windows question
try taking the .xls out.. Windows("Book1").Activate -- Bearacade ------------------------------------------------------------------------ Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016 View this thread: http://www.excelforum.com/showthread...hreadid=554196 |
Macro switch between windows question
Hi I guess the problem is that new workbooks won't always be called "book1". You could save the new workbook as soon as it's opened in the macro, thereby giving it a set name and changin the macro to reflect that name. Alternatively you could prompt the user to tell the macro what the workbook name is and then refer to that. Hope this helps Colin -- Colin Vicary ------------------------------------------------------------------------ Colin Vicary's Profile: http://www.excelforum.com/member.php...o&userid=10472 View this thread: http://www.excelforum.com/showthread...hreadid=554196 |
Macro switch between windows question
This should work if you have only two workbooks open:
For j=1 to workbooks.count if workbooks(j).name<activeworkbook.name then workbooks(j).activate exit for end if next j James punter wrote: Hi, I have a macro that is flipping between two windows. I recorded it and I'm running into an error. The sheet I was playing around with and recorded it on was called Book1. The macro will be run on sheets with different names. The debugger is highlighting this line: Windows("Book1.xls").Activate How do I make windows go the other open workbook no matter what the name is? Thanks Eddie -- punter ------------------------------------------------------------------------ punter's Profile: http://www.excelforum.com/member.php...fo&userid=2044 View this thread: http://www.excelforum.com/showthread...hreadid=554196 |
All times are GMT +1. The time now is 04:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com