Macro to open workbook and set as current active workbook

Tom Allen

Board Regular
Joined
Sep 26, 2014
Messages
92
Hi I am using the following code to open another workbook and it works great. However I was wondering how it could be adapted so that when it opens the workbook it also makes the newly open workbook the current active workbook on screen.

At the moment it opens but I remain on my current workbook.

Code:
Sub Finance_Overview()
Application.ScreenUpdating = False
Workbooks.Open Filename:="D:\Finance\Finance Overview.xlsm"
ThisWorkbook.Activate
Application.ScreenUpdating = True
End Sub

I would be grateful for any help.
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

lakshya2425

New Member
Joined
Oct 2, 2014
Messages
9
Hi I am using the following code to open another workbook and it works great. However I was wondering how it could be adapted so that when it opens the workbook it also makes the newly open workbook the current active workbook on screen.

At the moment it opens but I remain on my current workbook.

Code:
Sub Finance_Overview()
Application.ScreenUpdating = False
Workbooks.Open Filename:="D:\Finance\Finance Overview.xlsm"
ThisWorkbook.Activate
Application.ScreenUpdating = True
End Sub

I would be grateful for any help.




Sub abc()


Dim wb As Workbook, wb1 As Workbook
Dim xpath As String


Set wb = ThisWorkbook




xpath = "C:\Users\lakshya\Desktop\excel & vba training\copy.xlsx"


Set wb1 = Workbooks.Open(xpath)
wb1.Activate
' now u can write the code
wb1.Close (False)
wb.Activate


End Sub
 

Tom Allen

Board Regular
Joined
Sep 26, 2014
Messages
92
Thanks for the reply. I'm quite a novice at this so I don't suppose you could elaborate a bit more could you. I'm guessing I need to enter something into where you have put "now u can write the code" but I'm not sure what.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,923
Messages
5,621,625
Members
415,848
Latest member
LCC

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
Top