title: Switch between workbooks
body: <p>I have a code that searches for a certain information in another workbook, but that workbook changes names and formats. I am currently using workbook.open to open it, and when I specify the file location it has a dynamic part (you will understand on the sample code). The problem is that in the middle of the code I need to go back to the first workbook (the one running the code), do some stuff, then go back again to the workbook it searched the info on. I tried setting it as a variable using dim secondfile as string/workbook (tried both) and then tried to set it as the active workbook when it was "active", so I could use "secondfile.activate" later on when I needed to go back to it, but had no luck. Here is the code:</p>
  
  <pre><code>dim originalworkbook as workbook
  set originalworkbook as this workbook
  dim wb as workbook
  set wb as Workbooks.Open("C:\Users\abc\Documents\bla bla bla " + Range("D6").Offset(iLoop).Value)
  'code here...
  originalworkbook.activate
  'code here...
  '[insert code here to go back to the wb workbook]
  </code></pre>
  
  <p>I cannot tell it to open the wb workbook again because it would not make sense. Right now I have list with 1k+ data that is searched in another more than 30 files. The name of the file is on the first workbook, at least part of it, as you can see in the code. I use the "Range("D6").offset" part to get it. The thing is, it would take too long to run the code if I closed and opened the second workbook everytime, so what I am trying to do is to search for all things that are in a specific file and after searching it all, saving and closing it. That is why I need to get back to this file...</p>
  
  <p>PS: not all files are in the same format, thats why I didn't use "workbooks.activate" or something like it and then use the same "Range("D6").offset" thing to set the file to activate, because some are in .xls and others are in xlsx...</p>