Active Workbook

  • Thread starter Thread starter halem2
  • Start date Start date
H

halem2

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:
 
In a Module, try:

Sub aa()
If Workbooks(1).Name = "wb1" Then
Workbooks(2).Activate
Else
Workbooks(1).Activate
End If
End Sub
 
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
 
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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top