Need help opening files based on user input

andreroux1

New Member
Joined
Mar 24, 2016
Messages
1
Good day all I need to do a macro, where the user is prompted for input, which can be any value from 1 to 50. the input must then be combined with ".xls (resulting in a filename for example 5.xls if the user entered "5" at the ptompt.) Once that is done, I need to open the files with the same names in 3 different folders (for example c:\documents\folder A, c:\documents\folder B and c:\documents\folder C). I am not familiar enough with VBA or SQL to do this in a macro. Anyone with ideas?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try this:

Code:
Option Explicit


Sub OpenThree()
    Dim FileNr As Integer
    FileNr = InputBox("Provide a File Nr between 1 and 50")
    Dim FileA As String, FileB As String, FileC As String
    FileA = "c:\documents\folder A\" & FileNr & ".xls"
    FileB = "c:\documents\folder B\" & FileNr & ".xls"
    FileC = "c:\documents\folder C\" & FileNr & ".xls"


    Workbooks.Open FileA
    Workbooks.Open FileB
    Workbooks.Open FileC


End Sub
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,216,446
Messages
6,130,690
Members
449,585
Latest member
Nattarinee

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