Private function ProcessInvoice()
SparepartData = GetSparepartData(StrUniInvoiceNo(datarow))
SparepartDatarow = Application.WorksheetFunction.Index(SparepartData, 1, 0)
End Function
Private Function GetSparepartData(StrInvoiceNumber)
Application.ScreenUpdating = False
Application.Calculation = xlCalculateManual
Application.EnableEvents = False
'Set objRecordSet = RunSQL("C:\Users\karora3\OneDrive - Deloitte (O365D)\Documents\BMW Germany\Docs\test1.xlsx", "Select [BUNO],[RECHNR],[RECHDAT],[AUF_ART],[SELBZAHLER],[TYP_KEY],[BAUREIHE],[ERSTZULASSUNG],[AW_NUMMER],[AW_MENGE],[TEILENUMMER],[TEILE_MENGE],[STORNO],[STORNO_TXT],0,[RABATT] from [CalculationSheet$] where [RECHNR] ='" & StrInvoiceNumber & "' AND [TEILENUMMER] Is Not Null")
Set objRecordSet = RunSQL("C:\Users\karora3\OneDrive - Deloitte (O365D)\Documents\BMW Germany\Docs\test1.xlsx", "Select [BUNO],[RECHNR],[AUF_ART]from [CalculationSheet$] where [RECHNR] ='" & StrInvoiceNumber & "' AND [TEILENUMMER] Is Not Null")
SparepartTableArr = RecordsetToArray(objRecordSet)
Set objRecordSet = Nothing
Application.ScreenUpdating = True
Application.Calculation = xlCalculateAutomatic
Application.EnableEvents = True
GetSparepartData = SparepartTableArr
End Function