Remove Last Element
This function will return the last element in a concatenated string.
Public Function RemoveLastElement(ByVal sConCat As String, _
ByVal sSeparatorChar As String) _
As String
RemoveLastElement3 = VBA.Mid(sConCat, VBA.InstrRev(sConCat, sSeparatorChar) + 1)
End Function
Public Function RemoveLastElement2(ByVal sConCat As String, _
ByVal sSeparatorChar As String) _
As String
Dim arArray As Variant
arArray = VBA.Split(sConCat, sSeparatorChar)
RemoveLastElement2 = arArray(UBound(arArray))
End Function
Public Function RemoveLastElement3(ByVal sConCat As String, _
ByVal sSeparatorChar As String) _
As String
Dim sreverse As String
Dim ifind As Integer
sreverse = VBA.StrReverse(sConCat)
ifind = VBA.Instr(1, sreverse, sSeparatorChar)
If (ifind > 0) Then
RemoveLastElement3 = VBA.StrReverse(VBA.Left(sreverse, ifind - 1))
End If
End Function
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev