Open Workbook from Input

Bodie_D

New Member
Joined
Nov 29, 2021
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hello. I'm an old-timer (retired) and am going to try and learn some programming.
Not sure that's possible for someone over 60 with no programming experience.
I have a beginners book coming from Amazon tomorrow.

I'm trying to open an Excel file on my desktop with VBA.

Here's my simple code which doesn't work.

VBA Code:
Sub Test_Open()

Dim Team As String

Team = InputBox("enter team")

Workbooks.Open "C\Users\Bodie\Desktop\Team.xlsx"

End Sub

Appreciate any help. Thank you.......Bodie
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Assuming the name of the file is not "team.xlsx" and will be whatever the user entered.xlsx?
taking a stab in the dark here...Try:
Workbooks.Open "C\Users\Bodie\Desktop\" & Team & ".xlsx"
 
Upvote 0
The error box read 'file not found", but thanks for the respone, CM

The code you gave me seems logical.
 
Upvote 0
Hi & welcome to MrExcel.
Whar is the name of the file & what exactly are you typing into the inputbox?
 
Upvote 0
Hey CM and Fluff.

The name of the file is atl.xlsx

Its on my desktop.

i'm typing atl into the input box.

I'm pretty sure I have my path correct.

Thanks.....Bodie
 
Upvote 0
I just noticed, you'll need a colon : after the C...ie c:\users...
 
Upvote 0
Solution
Hey good catch, CM.

I put the colon in and it worked!

Thank you and Fluff for your help.

Looking forward to getting my beginners book tomorrow.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
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