I have two two different excel files and those two excel files i have to download regular basis and use vlookup ( File name like invoice report 30Apr2024__3636) other file name ( Po 30Apr2024_3737)
Instead Of Using VlookUP , u can try with the LINQ , it’s will provide the expected output in short time .
Create A variable - updatedDataTable (Data Table - Var Type)
updatedDataTable =
From row1 In DataTable1.AsEnumerable()
Group Join row2 In DataTable2.AsEnumerable()
On row1(“PO_Name”).ToString() Equals row2(“PO_Name”).ToString() Into Group
From row2 In Group.DefaultIfEmpty()
Select NewDataRow = {
If(row2 Is Nothing, “NA”, row2(“Column1”)),
If(row2 Is Nothing, “NA”, row2(“Column2”)),
If(row2 Is Nothing, “NA”, row2(“PO”) = row1(“PO_Name”))
}
).CopyToDataTable()
and finally use the write range to write the output data
Dim rowsToRemove = dtInput.AsEnumerable().Where(Function(row) row.Field(Of String)("ID").Equals("#N/A")).ToList()
For Each rowToRemove In rowsToRemove
dtInput.Rows.Remove(rowToRemove)
Next