Open Latest File By Date Modified
Feb 29, 2008
I have manged to search for the last updated file on a folder but i want to use the filename as the source for a copy and paste. it all seems to work bar the linking of the 2 processes the error message 'run time error 9 subscript out of range' is the file is already open should it just not use the same variable to copy the files?
Option Explicit
Sub Get_Availability_Data()
Application. ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Dim wsTo As Worksheet, wsFrom As Worksheet
Dim myDir As String, fn As String, a(), n As Long, myFile As String
Dim myDate As Date, temp As Date
myDir = "C:BarkingEMCIN"
fn = Dir(myDir & "*.csv")
Do While fn <> ""
temp = CreateObject("Scripting.FileSystemObject").GetFile(myDir & "" & ................................................
View 9 Replies
ADVERTISEMENT
Aug 6, 2014
I have this code, it's working to open the last modified file but how can I implement that it also opens a certain file name.
examples
Test1 150126.xls
Test1 150128.xls
Test1 150140.xls
the numbers are the time the file is saved, is it possible to also look at file name:text1 and then look at the last modified file So only fill in the file name and the macro opens file: Test1 150140
[Code] .....
View 5 Replies
View Related
Feb 11, 2013
I'm on excel 2010 and I have a small group excel files I open everyday. Most of the files are static in name and location. I've got a macro created to open those files, which works fine with workbooks.open and the file path.
There are two report files I want to incorporate into my macro of workbooks to open. The files are created weekly and the files names have the following format: "Report Name (YYYY-MM-DD).xlsm". I don't want to use the file's last modified date because older files may get edited after the more recent ones are created. The files are also not always created on the same day, so the solution needs to be flexible enough to not refer to a specific day of the week or anything.
Macro open an excel file based on the latest date found in filename.
View 9 Replies
View Related
Sep 16, 2009
I have a list that show file names and when the necessary works on these files were completed, but the powers that be want more. I have been asked to add two more columns, one showing when the file was last opened and the other when it was last modified.
Is it possible to do this through VBA without having to open the files that are listed? If so I will run the macro when the workbook is first opened.
View 10 Replies
View Related
Jan 9, 2014
I've written a Function which will count the number of files in a folder which the modified date equals a fixed date
For example, here, I want the file count which modified date = 01.01.2014
Code:
Function FileCountDate(Path As String, FileType As String) As Long
Dim strTemp As String
Dim lngCount As Long
Application.Volatile
strTemp = Dir(Path & FileType)
Do While strTemp ""
[Code] ......
However I got a #VALUE! error message with this formula:
=FileCountDate("C:Usersjohn.doeDesktopTEST","*")
In the TEST folder there are 4 pdf files so it should return the value of 4.
View 2 Replies
View Related
Feb 26, 2013
I have a workbook that column C has computer names starting from C4 to C83. I need to get the Datelastmodified of a log file that robocopy is writting to the following path. \Server1folder1WorkSheetName\%computername%somefile.log. The Datelastmodified needs to be entered in column K for each computer name in column C. One last thing would also be great is if the file does not exist it would write a error value.
View 1 Replies
View Related
Jan 8, 2007
I need to be able to find out which of two .txt files were most recently modified, the two txt files are of fixed name so I can hard code these.
View 2 Replies
View Related
Sep 21, 2009
if there's any sort of script which allows the file's last modified date to be shown in a worksheet?
View 5 Replies
View Related
Jul 11, 2009
How can display the last modified date and time of my excel file in a particular cell - Say in cell E1.
This is the same value that we get when we Right Click excel file->Properties->General and look at the label "Modified".
View 8 Replies
View Related
Jul 3, 2014
Below Macro which I am using to extract .PDF files. Now, I also want to see the Date moified while extracting the .PDF files. Hence, adding date modified to this macro.
Sub get_pdf_name()
Dim FR As Long, sh As String, FPath As String, FName As String
sh = Sheets("Sheet2").Name
FR = Sheets(sh).Range("A" & Rows.Count).End(xlUp).Row + 1
[Code] .....
View 1 Replies
View Related
Apr 8, 2008
I want to amend the ' Date Modified' for a spreadsheet. I have just made changes to it - so the 'Date Modified' shows today's date and time. Is there a way of changing the 'Date Modified' so it shows as yesterday's date?
View 3 Replies
View Related
Jun 4, 2009
I'm working on the following
Workbooks.Open Filename:= _
"D:CommondataIBMmainBRANCHBURG-PRODUCTS-BOM-ALUMINUM-UPDATE-" & Ucase(Format(DateAdd("y", 0, Date)), "YYYY-MM-DD")&".XLS"
ChDir "D:CommondataIBMmain"
ActiveWorkbook.SaveAs Filename:= _
"D:CommondataIBMmainBRANCHBURG-PRODUCTS-BOM-ALUMINUM-UPDATE-NAFTA.XLS", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Date: 2009-06-03
What I'm trying too do is open a file, make an exact copy and save it under a new file name.
My problem is in the date formula the day is not always the same. In the sample case it's 03 at other times the day will change.
is there a way too get this too work irregardles of what the day might be?
View 9 Replies
View Related
Feb 8, 2013
I do routine tasks every day which involves opening 3 different files and pasting data into my main file. The data is always in the same format, and the 3 files are saved in the same location (3 different folders through). The 3 files are saved each day and the naming convention is constant, with only the date changing. For example, the files are always saved in C:My Documents and the files are called test_05.02.2013.xls. Tomorrow the file will be called test_06.02.2013.xls and so on.
So each day I will be rolling a file forward and I want to bring in the info from each of these files based on the new day.
How to do 1, and I will do the others (because the concept will be the same).
View 1 Replies
View Related
Apr 24, 2014
I need to open an excel file based on a date mentioned in the file name, but minus 1 day. The file name is composed with Statistics_date_time.xls
Example: statistics_20140423_142754.xls
Once I need to open the file (only in the mornings), it has to be the one from the previous day to see the yesterdays performance. How can I create a macro that will look at the date in the file and take the one from yesterday?
This will be a part of a macro I'm making. The rest of the macro will just format the file and combine a few ones from different departments.
View 4 Replies
View Related
Feb 25, 2009
how can you automatic the date to today's date when you open the excel file?
ie.
Price Report For 02/25/09
View 5 Replies
View Related
Jul 26, 2012
I am trying to write a macro to complete a report for me. I have everything working and tested but I have 1 issue. The report needs to take some data from yesterdays report.
Therefore I need a code which is able to open the file, I know how to do this with a constant file name but the issue arises because the file from yesterday is saved with the date.
i.e. filename250712 etc..
View 3 Replies
View Related
Nov 19, 2004
Probably not possible but can you write a macro to load a file which has a file name which always starts with Act2July followed by the date
i.e. Act2July191104.xls
but next friday it will be called Act2July261104.xls
This file is created by the network.
So can the macro pick up the Act2July part of the file name and then select the file dependent on when it was saved, so that the latest update is always loaded.
View 9 Replies
View Related
Aug 6, 2013
I have a csv file named "BB31_2013-08-01". I would like to open this file via vba and this is not my only file. I also have another similar fileames such as "BB31_2013-08-08", therefore, I try to create some function like yyyy, mm & dd where I can modifie it easily for next file.
Here is my code:
VB:
'change weekly
yyyy = "2013"
mm = "08"
dd = "01"
Workbooks.Open Filename:= _
"C:Documents and Settings1314228DesktopTest ProgressBB31& yyyy &-& mm &-& dd.csv"
[Code] .....
View 3 Replies
View Related
Apr 2, 2014
Previous to a PC meltdown a few months ago, when I opened my monthly customer list file the account date would automatically update to the current date. After the PC repair, reinstall of MS Office 2002 (same version as before the PC death) and copying of documents back to their old locations, I now have to update this manually for all accounts each time I open it. I have searched through the options and customize menus but there is no mention of this setting. Before, it just did it from day one (5 years ago) without any setup.
How do I get back the old auto-date update preference?
View 1 Replies
View Related
Dec 22, 2008
I don't really know VBA more than just piecing together other people's work (so please dumb down your responses as much as possible).
So I would like to have a function that displays a filename within a cell. The filename I need to display will start with "cost" and have a date at the end (not always the same number of characters). I need to search a folder for all files that contain that text and return the last modified one.
I found this VBA code that returns the last modified file, but only filters based on the extension (which I would like to keep in the code as well).
View 11 Replies
View Related
Apr 16, 2014
I have the current code that opens our raw data file and copys it into my workbook. However it now turns out the file is saved everyday as a new file with todays date on the end. Here is my current code:
Sub CopyRaw()
Application.DisplayAlerts = False
Sheets("PROD_SELECTION").Visible = True
Sheets("PROD_SELECTION").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
[Code] .....
Todays file is now in the name "I:SalesSales and MarketingMarketing List Product Selection Details (20140416)"
I know i can do this somehow using the Date function but the closest I have got is using
"YEAR(NOW())&RIGHT(MONTH(NOW())+100,2)&DAY(NOW())"
To generate todays date like so: "20140416" but I dont know how to get that into my code correctly so i open the file with that on the end.
View 1 Replies
View Related
May 29, 2014
I need a code which will open up a previous days file. I have the code to pick the correct file but I am stuck because the folders are multiple levels down to year then month.
Eg. Folder Name > YYYY > Month
So i need to have a code which can look in to the relevant folder based on the current date and then be able to open the file i need.
I.e. today is 29May so i need the code to open the 2014>May folder.
For 1st day of month I would need it to open last months folder I.e. 01June Open May folder
View 2 Replies
View Related
Jun 5, 2009
Is there a way to open a file similair to
fMask="Post Biz Voice Installs QC Report*.TXT"
varFiles = Application. GetOpenFilename("TEXT Files,"&fMask, 1, "Please select all the Post Biz Voice Installs QA Report files", , True)
I want to filter the filenames to only certain prefixes
I am then importing the files and populatin the ws
Here is my whole module so it can be seen in context
Sub GetBCDV()
Dim varFiles As Variant
Dim SourceBook As Workbook, TargetBook As Workbook, strAddress As String ', 1 As Integer
Call Archive_WB_BCDV
fMask="Post Biz Voice Installs QC Report*.TXT"
varFiles = Application.GetOpenFilename("TEXT Files,"&fMask, 1, "Please select all the Post Biz Voice Installs QA Report files", , True)
View 5 Replies
View Related
May 5, 2008
I'm looking for a code which is checking the file name first before opening and operating on it. File name format is filenameyyyymmdd.xls but the problem is files in that directory are saved irregularly (couple times a week) and I need to open the newest saved file.
View 2 Replies
View Related
Apr 17, 2007
Is there a way I can check an excel workbook's created and last modifed dates using a macro in that same workbook?
View 3 Replies
View Related
Feb 10, 2012
I have an excel spreadsheet with multiple file names (including file path) listed in a column. I have to update other files using these 'underlying' files. So each cell has the file path and file name (i.e. Q:FolderFile Name.xls). I would like to have the adjacent cells indicate the last modified date for each file. This saves me time from looking for the last modified date manually across different folders in my servers to see if the 'underlying' file has been updated, which I would need in order to update my other files.
So this function would be something like "get last modified date based on file path". I will need step by step instructions as I am not very familiar with VBA.
Example:
A B
1 Q:Folder1File name1.xls 2/10/2012
2 X:Folder2File name2.xls 12/1/2011
View 4 Replies
View Related
Feb 23, 2010
I am sure this is easy but i cant for the life of me find the code for this:
I am trying to have a MSG Box popup after opening a file and it displays the date the current file was last modified with an "OK" button on it to close the box.
View 9 Replies
View Related
May 13, 2006
I have a number of excel files in a directory that require me to take action after a file has been saved. What I want to do is create a macro that will look to each file and retrieve its 'modified date', then put that into a spreadsheet. What would be ideal is to create a User Defined Function to look at the last modified date of a file in the cell next to it (I have the files names in a spreadsheet as a hyperlink).
View 2 Replies
View Related
Sep 15, 2014
I managed to create some code that will connect to a workbook and take the data from there.
It is kind of SQL mixed with VBA. I just got this by finding it in google (I don't have the link handy now).
What the file does, is it will take 2 columns from a workbook called "Test.xls" and then take out 2 columns "Name" and "ID".
The only thing is, this is only a test and not the actual files I need to open. the files are always saved on the same folder, but the name is the day of the export of it. So when I export a file today, it will get 2014.09.10.xls. The sheet (only 1) will also get that name.
How could I change the below code that it will take that file based on today's date and read from the sheet with today's data?
VB:
Sub sbADO()
Dim sSQLQry As String
Dim ReturnArray
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
'DBPath = ThisWorkbook.FullName
[Code] ....
View 9 Replies
View Related
Jun 10, 2009
I want to know if there is a way to have a cell beside a series of cells that will change its date (and time) when any of the cells in the series is changed.
On a single row, I have four materials that total to a fifth cell. The 6th cell in that row, I would like to have a "date last modified" that would change if any of the first five cell's value is changed.
View 9 Replies
View Related