Select Misc Workbook with VBA

tcnt9176

Board Regular
Joined
Jun 23, 2008
Messages
223
There is probably a real simple code but I looked around and could not find it. At any given point I will have two workbooks open, one will remain and the other will be closed and another one open so the workbook name will change. How do I get VBA to select the inactive workbook since the name will change? I hope that makes sense.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm sorry it doesn't quite make sense, to me anyway.:)

What are you actually doing with these workbook(s) and where is the code located?

You can refer to whatever workbook the code is in using ThisWorkbook and you can create a reference to a workbook when you open, like this perhaps.
Code:
Set wbThis = ThisWorkbook
 
Set wbOpen = Workbooks.Open("C:\WorkbookX.xls")
 
' work with wbOpen
 
' close worked book that was opened
 
wbOpen.Close
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,290
Members
449,218
Latest member
Excel Master

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