Function RemoveTrailingPipe(cell As Range) As StringDim str As Stringstr = cell.Value ' Get the value from the passed-in cellIf Right(str, 1) = "|" Then ' Check if the last character is a pipe (|)RemoveTrailingPipe = Left(str, Len(str) - 1) ' Remove the last character (pipe)ElseRemoveTrailingPipe = str ' If there's no trailing pipe, return the string as-isEnd IfEnd Function