Activate other open excel file

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
1,012
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Hi all,

Macro to activate other open excel file which each time can have different file names.

Thank you in advance.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Your request is to general to offer a solution. How about some specifics.
 
Upvote 0
Thank you Alan for reply.

Let say my master file name is “Master.xlsm” & it is active. There is another source excel file with name “Items-2021.xlsx” which is open but not active. I would like activate this file & take some data from it. The problem is that next time source file will have different name, let say “Items-62.xlsx”, so it will be not good idea each time to make source file name changes in macro. I need macro which will activate any file with different names with same macro.
 
Upvote 0
When you open it, assign a workbook variable

Code:
set myWkb = workbooks.open(whatever)
...
myWkb.activate
 
Upvote 0
Hi SHG.

Thank you very much for reply.
Am I Missing Something Here? Here is my code:
Code:
Sub Activate_OtherBook()
    Set myWkb = Workbooks.Open(whatever)
    myWkb.Activate
End Sub
Im getting Run-time error ‘1001’:
“ could not be found. Check the spelling of the file name, and verify that the file location is correct.
 
Upvote 0
Are you opening the workbook in code?
 
Upvote 0
Yes, I think i misunderstand your "When you open it, assign a workbook variable"
 
Upvote 0
Post the code you're using to open the workbook.
 
Upvote 0
Code:
Sub Activate_OtherBook()
    Set myWkb = Workbooks.Open()
    myWkb.Activate
End Sub
 
Upvote 0
That's not the code you're using -- it doesn't compile.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top