Notifications
Announcements
Dim objExcelBOM, objWbkBOM, objExcelArrow, objWbkArrow Dim i, lastRow, j Dim Count, cell Dim FirstCol, SecondCol, ThirdCol, FourthCol 'Dome Output Template Set objExcelBOM = CreateObject("Excel.Application") Set objWbkBOM = objExcelBOM.Workbooks.Open("%Output_Files[1].FullName%") Set objExcelArrow = CreateObject("Excel.Application") Set objWbkArrow = objExcelArrow.Workbooks.Open("%Arrow_BOM_Files[0].FullName%") objExcelBOM.Visible = True objExcelArrow.Visible = True Set objWkshtBOM = objWbkBOM.Sheets("Sheet1") Set objWkshtArrow = objWbkArrow.Sheets("Best Buying Options") lastRowBOM = objWkshtBOM.Cells(objWkshtBOM.Rows.Count, "B").End(-4162).Row lastRowArrow = objWkshtArrow.Cells(objWkshtArrow.Rows.Count, "B").End(-4162).Row Count = 2 For i = 2 To lastRowBOM For j = 2 To lastRowArrow If objWkshtArrow.Range("B" & i).Value = objWkshtBOM.Range("B" & j).Value Then If objWkshtArrow.Range("F" & i).Value = "-" Or IsEmpty(objWkshtArrow.Range("F" & i).Value) Then objWkshtBOM.Range("P" & j).Value = "" objWkshtBOM.Range("Q" & j).Value = objWkshtArrow.Range("F" & i).Value objWkshtBOM.Range("R" & j).Value = objWkshtArrow.Range("I" & i).Value objWkshtBOM.Range("S" & j).Value = objWkshtArrow.Range("Q" & i).Value ElseIf IsNumeric(objWkshtArrow.Range("F" & i).Value) Then objWkshtBOM.Range("P" & j).Value = objWkshtArrow.Range("M" & i).Value objWkshtBOM.Range("Q" & j).Value = objWkshtArrow.Range("F" & i).Value objWkshtBOM.Range("R" & j).Value = objWkshtArrow.Range("I" & i).Value objWkshtBOM.Range("S" & j).Value = objWkshtArrow.Range("Q" & i).Value End If End If Next Next ' Save and close the workbooks objWbkBOM.Save objWbkArrow.Save ' Close the workbooks objWbkBOM.Close objWbkArrow.Close ' Quit the Excel applications objExcelBOM.Quit objExcelArrow.Quit ' Clean up the objects Set objWkshtBOM = Nothing Set objWkshtArrow = Nothing Set objWbkBOM = Nothing Set objWbkArrow = Nothing Set objExcelBOM = Nothing Set objExcelArrow = Nothing
import pandas as pd # Load the Excel files df1 = pd.read_excel(r"C:\Users\Desktop\Power Automate Desktop\Projects\BOM Costing\Phyton Output\Output.xlsx") df2= pd.read_excel(r"C:\Users\Desktop\Power Automate Desktop\Projects\BOM Costing\DLM Folder\Material with Latest Purchase Price.XLSX") # Iterate over each row in df1 for index, row in df1.iterrows(): dlm_part_no = row['DLM Part Number'] # Find matches in df2 based on 'Material' column match = df2.loc[df2['Material'] == dlm_part_no, 'Price in USD'] # Check if there is at least one match if not match.empty: # Take the first match (if there are multiple, or you can handle them differently) price = match.iloc[0] # Update the 'DLM Price' column in df1 df1.at[index, 'DLM Price'] = price # Save the updated df1 to a new Excel file df1.to_excel(r"C:\Users\Desktop\Power Automate Desktop\Projects\BOM Costing\Phyton Output\Output1.xlsx",index=False)