Code:
Sub LastModifiedFile()
Dim dirName As String
Dim fName As String
Dim fileTime As Date
Dim FileName As String
Dim LatestFile As String
Dim wbSource As Workbook
Dim wbFile As Workbook
Dim LR As Long
Set wbSource = ActiveWorkbook
dirName = "P:\New Issues\"
fName = Dir(dirName & "*.*")
While fName <> ""
If FileDateTime(dirName & fName) > fileTime Then
LatestFile = fName
fileTime = FileDateTime(dirName & fName)
End If
fName = Dir()
Wend
If LatestFile = "" Then
MsgBox "There are no files in the directory"
Else
Workbooks.Open dirName & LatestFile
Set wbFile = ActiveWorkbook
With Sheets("Data")
LR = .Range("B" & Rows.Count).End(xlUp).Row
.Range("B24:G" & LR).Copy Destination:=wbSource.Sheets("Sheet3").Range("A1")
wbFile.Close
End If
End Sub
This is what I have so far, basically I want to open up the most recently modified file in a folder copy the range of data that I mentioned at the top of the thread from that workbook. Paste the data onto "sheet3" in the source workbook where the macro will be triggered then close the workbook from where the data was copied.