I have order numbers and quantities recorded like this: # 5397 (5) # 5387 (15) which means 5 and 15, in total 20. The expected result is 20.
I already have a custom function implemented in Microsoft Excel VBA:
Function SUMAPA(n1 As String)Longitud = Len(n1)For i = 1 To LongitudIf Mid(n1, i, 1) = "(" ThenIf Mid(n1, i + 2, 1) = ")" ThenValor = Val(Mid(n1, i + 1, 1))SUMAPA = SUMAPA + Val(Mid(n1, i + 1, 1))ElseIf Mid(n1, i + 3, 1) = ")" ThenValor = Val(Mid(n1, i + 1, 2))SUMAPA = SUMAPA + Val(Mid(n1, i + 1, 2))ElseIf Mid(n1, i + 4, 1) = ")" ThenValor = Val(Mid(n1, i + 1, 3))SUMAPA = SUMAPA + Val(Mid(n1, i + 1, 3))ElseIf Mid(n1, i + 5, 1) = ")" ThenValor = Val(Mid(n1, i + 1, 4))SUMAPA = SUMAPA + Val(Mid(n1, i + 1, 4))ElseIf Mid(n1, i + 6, 1) = ")" ThenValor = Val(Mid(n1, i + 1, 5))SUMAPA = SUMAPA + Val(Mid(n1, i + 1, 5))ElseIf Mid(n1, i + 7, 1) = ")" ThenValor = Val(Mid(n1, i + 1, 6))SUMAPA = SUMAPA + Val(Mid(n1, i + 1, 6))End IfEnd IfNext iDebug.Print ValorDebug.Print SUMAPAEnd FunctionIt works well in Excel:
I want to do the same thing in Google Sheets.
