View Single Post
  #5   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Mon, 6 Dec 2004 05:43:04 -0800, "carl"
wrote:

I have a string like so:

ab;cd;ef;gh

is there a way to reverse the order ? eg:

gh;ef;cd;ab

Thank you in advance


Easy with VBA.

<alt-F11 opens the Visual Basic Editor.

Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window that opens.

To use this, enter the function =REV(string, separator) into some cell. String
and Separator can either be actual strings, or cell references that contain
strings. As written, each variable must be in a single cell. But the UDF can
be rewritten if that is not suitable.

=======================
Function Rev(str As String, sep As String) As String
Dim temp, temp1
Dim i As Integer

temp = Split(str, sep)
ReDim temp1(UBound(temp))

For i = 0 To UBound(temp)
temp1(UBound(temp) - i) = temp(i)
Next i

Rev = Join(temp1, sep)

End Function
========================


--ron