Alvaroro84
Board Regular
- Joined
- May 13, 2022
- Messages
- 65
- Office Version
- 2016
- Platform
- Windows
I want the macro to pick up the most recent Xl Doc from the My path=F:\VMWare\" location I'm just not sure what else to add to make it pick the most recent
VBA Code:
Sub macro2()
'
'
Dim LastRow As Long
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim LMD As Date
Dim WB As Workbook
Set WB = ActiveWorkbook
LastRow = Sheets("Sheet1").UsedRange.SpecialCells(xlCellTypeLastCell).Row
MyPath ="F:\VMWare\"
Range("D2").Select
ActiveCell.Formula2R1C1 = _
"=XLOOKUP(RC[-3],'[" & MyPath & "]Cos'!C3,'[" & MyPath & "]Cos'!C4,0)"
Selection.AutoFill Destination:=Sheets("Sheet1").Range("D2:D" & LastRow), Type:=xlFillDefault
End Sub