Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
punter
 
Posts: n/a
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bearacade
 
Posts: n/a
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.misc
Colin Vicary
 
Posts: n/a
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.misc
Zone
 
Posts: n/a
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro question punter Excel Discussion (Misc queries) 10 June 12th 06 11:15 PM
general macro question ynissel Excel Discussion (Misc queries) 17 February 24th 06 03:15 PM
Macro Button Question mariat Excel Discussion (Misc queries) 4 December 1st 05 02:21 AM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Bob Phillips followup question on text macro kayabob Excel Discussion (Misc queries) 2 June 27th 05 05:13 PM


All times are GMT +1. The time now is 11:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"