Hi Guys i have a code below and i need your help to modify it so it will be suitable for UiPath invoce code activity
thank you
Function compare(name1 As String, name2 As String) As Long
' (1) Handle the YTD-Case:
If Left(name1, 3) = "YTD" And Left(name2, 3) <> "YTD" Then
compare = -1
ElseIf Left(name1, 3) <> "YTD" And Left(name2, 3) = "YTD" Then
compare = 1
Else
' Compare the names without the leading number
Dim pieces1() As String, pieces2() As String
pieces1 = Split(name1, "_")
pieces2 = Split(name2, "_")
If UBound(pieces1) > 0 And UBound(pieces2) > 0 Then
If pieces1(1) <> pieces2(1) Then
' different groups
compare = IIf(pieces1(1) < pieces2(1), -1, 1)
Else
' Same group, compare numbers
If pieces1(0) = "0" Then
compare = 1
Exit Function
ElseIf pieces2(0) = "0" Then
compare = -1
Exit Function
Else
compare = Val(pieces1(0)) - Val(pieces2(0))
End If
End If
Else
' Whatever that is: Compare names directly
compare = IIf(name1 < name2, -1, 1)
End If
End If
End Function