For example there are some files in folder, loop files in folder and it should search specific text in specified cells if text matches with cells file should save in specified path
This line am getting error"If Range("A6").Value = ("CORE SKUS ONLY: N").Value & If Range("A7").Value =("ECO SKUS ONLY: Y").Value Then
{{{{Sub OpenLatestFile()
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim rFind As Range
Dim strSearch As String
strSearch = "CORE SKUS ONLY"
Dim LMD As Date
MyPath = "C:Usersp_DivyankaDesktopDivyankaVendor MetricsUS"
If Right(MyPath, 1) <> "" Then MyPath = MyPath & ""
MyFile = Dir(MyPath & "RptLineItemFillRate_*.xls", vbNormal)
If Len(MyFile) = 0 Then
MsgBox "No files were found...", vbExclamation
Exit Sub
End If
Do While Len(MyFile) > 0
LMD = FileDateTime(MyPath & MyFile)
If LMD > LatestDate Then
LatestFile = MyFile
LatestDate = LMD
End If
MyFile = Dir
Loop
Workbooks.Open MyPath & LatestFile
Windows("RptLineItemFillRate_*.xls").Activate
ActiveWindow
If Range("A6").Value = ("CORE SKUS ONLY: N").Value & If Range("A7").Value =("ECO SKUS ONLY: Y").Value Then
Windows("RptLineItemFillRate_*.xls").Activate
ChDir "C:Usersp_DivyankaDesktopDivyankaVendor MetricsUSFY2018ING"
ActiveWorkbook.SaveAs Filename:= _
"C:Usersp_DivyankaDesktopDivyankaVendor MetricsUSFY2018INGUS_ING_Aged_Detail.xls" _
, FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close
Else
ActiveWindow.Close
End If
End Sub}}}}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…