I have two excel sheets both with product code and quantity
I need to grab quantity of a product code from an excel sheet and place it into another.
I will be searching the sheet for a product code then need to take the quantity of that product and then search for code in the other sheet and write the quantity beside.
Anyone know how to do this?
Let’s say you have source excel with product code and quantity, then destination excel with product code and a lot of other information. What you need to do is read range each of the excel into datatable e.g. dtSourceExcel and dtDestinationExcel. Add a data column to dtDestinationExcel named Quantity. Do a For Each row of dtDestinationExcel, and then inside it use a lookup data table for dtSourceExcel LookupValue is dtDestinationExcel(“Product Code”).ToString.Trim. Output is CellValue to variable strQuantity. Then have assign dtDestinationExcel(“Quantity”) to strQuantity.
Lastly, write range the dtDestinationExcel to your output file