ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Active Workbook (https://www.excelbanter.com/excel-programming/363756-active-workbook.html)

halem2[_66_]

Active Workbook
 

With two open workbooks and knowing the name of one only (let's call th
one we know the name of wb1.xls), is there a way to make wb1.xls th
inactive workbook and make the other one (we don't know the name) th
active one???

thanks:

--
halem
-----------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...nfo&userid=993
View this thread: http://www.excelforum.com/showthread.php?threadid=55013


AA2e72E

Active Workbook
 
In a Module, try:

Sub aa()
If Workbooks(1).Name = "wb1" Then
Workbooks(2).Activate
Else
Workbooks(1).Activate
End If
End Sub




halem2[_68_]

Active Workbook
 

the problem isI don't know the name of the other workbook until it is
emailed to me. I would need to edit the macro everytime if I use that
procedure.

I need to make the Active workbook the one I receive not wb1


--
halem2
------------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930
View this thread: http://www.excelforum.com/showthread...hreadid=550132


halem2[_69_]

Active Workbook
 

thanks. Tried it but doen not work

--
halem
-----------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...nfo&userid=993
View this thread: http://www.excelforum.com/showthread.php?threadid=55013


AA2e72E

Active Workbook
 
You said:

The workbook whose name you know is wkb1.xls; workbook(n).Name returns the
name of its workboom without extension xls.

The code has no reference to the name of the other workbook BUT it does
assume that you have it open in the same session of Excel.

Then the code works: it does what you asked for. That is make the 'other'
workbok the active workbook.

Did you ask for what you wanted?



halem2[_70_]

Active Workbook
 

I think I did... The actual error says "subscript out of range..erro
9".

both workbooks have several worksheets, one over 90 and the other on
over 30. When the macro worked, it would (using another sub I have
match the ws names on both and copy the cell ranges from one to th
other, then go to the next matching set of ws and do the same until i
copied all specified cell ranges from all ws.

it baffles me that it actually worked for a few weeks and it jus
stopped working. No one else has access to it and it is passworded

--
halem
-----------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...nfo&userid=993
View this thread: http://www.excelforum.com/showthread.php?threadid=55013



All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com