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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I'm asking what you're doing now, Sahak.
 
Upvote 0
Dear SHG,

I’m sorry for giving you hard time, the reason is my English is no good enough.
What I need is to take from open but not active Excel file some data & paste to master file.
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. In this case I know source file name & I can use in macro that file name to activate it, but next time source file will have different name, let say “Items-62.xlsx”, so it will be not good idea each time make source file name changes in macro. I need macro which will activate any Excel file with different names with same macro.
Thanks again for your help & patient.
 
Upvote 0
Right.

How can the code know which workbook to activate? Is it the only other workbook that's open?
 
Upvote 0
Can it look for some word in the beginning, in this case "Item_" * & ".xlsx" ?
 
Upvote 0
Sure:

Code:
Sub Sahak()
  Dim wkb As Workbook
  
  For Each wkb In Workbooks
    If LCase(wkb.Name) Like "item_*.xlsx" Then
      wkb.Activate
      Exit For
    End If
  Next wkb
  
  ' carry on ...
End Sub
 
Last edited:
Upvote 0
YES !!!!! you did it. Thank you VERY much & god bless you.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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