out_Str_input = Directory.GetFiles(in_ParrentFolder+"Input",“SSC*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0).ToString
And invoke VBA as below. How can I use variables instead link =‘D:\RPA\UiPath\ICS\Input[ICS.xlsx]
Sub Del_Rws()
Dim d As Object
Dim a As Variant, b As Variant, itm As Variant
Dim nc As Long, i As Long, k As Long
Instead of hardcoding the file path, you can try to pass the variable something like this:
out_Str_input = Directory.GetFiles(in_ParrentFolder+"Input","SSC*.xlsx").OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0)
Del_Rws(out_Str_input)
Sub Del_Rws(file_path as String)
Dim d As Object
Dim a As Variant, b As Variant, itm As Variant
Dim nc As Long, i As Long, k As Long
Sheet2.Range("A1:A1000").Formula = "='" & file_path & "PLHQ'!D20"
Sheet2.Range("A1001:A2000").Formula = "='" & file_path & "PLHQ'!E20"
End Sub
Sub Del_Rws(out_Str_input As String)
Dim d As Object
Dim a As Variant, b As Variant, itm As Variant
Dim nc As Long, i As Long, k As Long
Dim inputWb as Workbook
Set inputWb = Workbooks.Open(out_Str_input)
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
Dim fileName As String
fileName = fso.GetFileName(out_Str_input)
Sheet2.Range("A1:A1000").Formula = "='[" & fileName & "]PLHQ'!D20"
Sheet2.Range("A1001:A2000").Formula = "='[" & fileName & "]PLHQ'!E20"
Set d = CreateObject("Scripting.Dictionary")
a = Sheets("Sheet2").Range("A2", Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp)).Value
For Each itm In a
d(itm) = 1
Next itm
With Sheets("Sheet1")
a = .Range("C2", .Range("C" & Rows.Count).End(xlUp)).Value
ReDim b(1 To UBound(a), 1 To 1)
For i = 1 To UBound(a)
If Not d.exists(a(i, 1)) Then
k = k + 1
b(i, 1) = 1
End If
Next i
If k > 0 Then
Application.ScreenUpdating = False
nc = .Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
With .Range("A2").Resize(UBound(a), nc)
.Columns(nc).Value = b
.Sort Key1:=.Columns(nc), Order1:=xlAscending, Header:=xlNo
.Resize(k).EntireRow.Delete
End With
Application.ScreenUpdating = True
End If
End With
Sheet1.Range("H2:H2").Formula = "=SUM(D2:D1063)" 'Tong khoi luong
Sheet1.Range("I2:I2").Formula = "=ROUND(SUM(G2:G1063),2)" 'Tong gia
inputWb.Close SaveChanges:=False
End Sub