Activate a file which using input box

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, i would like to "Activate" a file which is open but using an input box by VBA. An example of command is below but therefore that the file (e.g. "PAYROLL.xlsx") should activate by input box.

Windows("PAYROLL.xlsx").Activate

Thanking you in advance
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try this:

I have set the default Workbook in the Inputbox.
Modify if you want:

Code:
Sub Activate_Workbook()
'Modified  9/19/2018  1:42:49 AM  EDT
On Error GoTo M
Dim ans As String
ans = InputBox("Enter Full Workbook Name", "Example:  PAYROLL.xlsx", "PAYROLL.xlsx")
Workbooks(ans).Activate
Exit Sub
M:
MsgBox "The Workbook" & ans & "  Is Not open"
End Sub
 
Upvote 0
No My Asw, it doesn't work and it appears a msg that, the the file is not open. Your post at 17 Sep works perfect. Just is missing the "Activate" command. It open the file which i enter in "Input Box" but it doesn't "Activate" it the file, so can u modify this post (17 Sep) so that to add the command by which when open the file to "Activate" it too? Many thanks in advance and thanks for your continuance support. Hv a great day
 
Upvote 0
Not sure what your saying.
I see no post here of 17 Sept.

This question was started on 19 Sept.
 
Last edited:
Upvote 0
Hi My, on 17th Sep, (previous post), you provided me support (VBA code) by which i can open a file by "Input Box" and just i need to modify or develop the code, so that, to "Activate" the file which opened.
Due to different files which i work, the file which i want to "Activate" should be choosing by "Input Box"

I would like to thank you once again
 
Last edited:
Upvote 0
OK. Not sure if you have a question. If you have a script I previously provided and now you want it modified you need to post the script here or start a new posting and explain what you want added.

I answer a lot of question here. And do not have that particular code handy.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

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