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.
 

BiocideJ

Well-known Member
Joined
Jan 23, 2012
Messages
1,733
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:

Forum statistics

Threads
1,081,415
Messages
5,358,533
Members
400,502
Latest member
price83

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top