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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub test()
Dim d As String
d = InputBox("Enter date, ddmmyy")
Workbooks.Open Filename:="C:\test\home\Test" & d & ".xls"
End Sub
 

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,899
Office Version
  1. 365
Platform
  1. Windows
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
 

Np72

Board Regular
Joined
Dec 22, 2010
Messages
108
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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,652
Messages
5,838,597
Members
430,557
Latest member
MK15

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