macro to find file

Np72

Board Regular
Joined
Dec 22, 2010
Messages
108
Hi,

Is there anyway that vba can find, open files. The files are always kept in the same place (for example C:test/home/Testddmmyy.xls) but the date changes everyday. Is there a way of inserting the date in a pop up box then vba will find and open the desired file in a template work book ??

Thanks

Neil
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try

Code:
Sub test()
Dim d As String
d = InputBox("Enter date, ddmmyy")
Workbooks.Open Filename:="C:\test\home\Test" & d & ".xls"
End Sub
 
Upvote 0
Something like:
Code:
Sub OpenSelectFile ()
Dim FileLocation as String, InputDate as String
FileLocation = "C:\test\home\Test"
InputDate = InputBox("Enter date of file (ddmmyy):", "File date required")
Workbooks.Open Filename:=FileLocation & InputDate & ".xls"
End Sub
 
Upvote 0
Cool, it works. However I forgot to add that the files are always called

H:\_TransfertPROD\InstitutionalAssetManagement\PamIT\Compliance\GVA\ISSCAP_Total_zero_GVA_YYMMDD.XLS

I tried inserting this into the macro but alas
 
Upvote 0
Try

Code:
Sub test()
Dim d As String
d = InputBox("Enter date, ddmmyy")
Workbooks.Open Filename:="H:\_TransfertPROD\InstitutionalAssetManagement\PamIT\Compliance\GVA\ISSCAP_Total_zero_GVA_" & d & ".xls"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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