Copying in data from file with date in folder name

booms

Board Regular
Joined
Dec 2, 2010
Messages
60
Hi,

I think this is probably quite straightforward - I'm trying to set up a macro that will copy in data from a file which is saved down daily.

The file is saved down in a different folder each day e.g. folder/13_May_2011/folder/XRATE_EXTRACT

How would I set up a macro that was able to pick up this folder location, being aware of the date (last business day), and date format?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
here is an example of setting the path and file name

Code:
Sub Xrate()
Dim XDir As String, sName As String, sPath As String, fName As String
XDir = Format(WORKDAY(Date, -1), "d_mmm_yyyy")
sPath = "C:\Documents and Settings\lynna0\Desktop\" & XDir
sName = "\" & "XRATE_EXTRACT"
fName = sPath & sName
Workbooks.Open fName
End Sub

note: untested
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

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