Macro to Activate Workbook

Gaura215

Board Regular
Joined
Feb 2, 2011
Messages
97
Hello

I have a requirement to to activate a workbook, with certain words in the name of that workbook.

It may be simple for you all excel gurus out there, but I have been straining my brain since morning on this.

I will explain a bit in detail. I have a template from which value in few cells (Fixed) needs to be copied to a seperate workbook. I know about this copy and paste thing. However the catch is that, this seperate workbook is not always of same name. However this seperate workbook definately contain "JE LOG" in its name. Is their a way, that my macro can consider my activeworkbook as "wb" or something else, and open the workbook containing "JE Log" in its name.

One thing is for sure, at a given time, only workbook with "JE Log" will be open.

Please help.

Thanks in advance.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I just typed this in the forum window, but this is what I use to activate a workbook when all I know is its name.
Code:
Sub ActivateJELog()
     For Each JEwb in Workbooks
          If UCASE(JEwb.Name) Like "*JE LOG*" Then
               JEwb.Activate
               Exit For
          End If
     Next JEwb
'You can then reference the JE Workbook with calls such as JEwb.Sheets(1).Range("A5").Value = "Hello World."
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,249
Members
448,879
Latest member
oksanana

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