Tuesday, January 23, 2018

Reverse the text order in excel with a new function

If you have data (for example a list of users in an Active Directory with full logon names) and you want to sort them via the OU they are in, this is a quick excel function to reverse the text and then you can sort away.


In Excel press ALT-F11

Paste in this code:

 Function reverse(S As String)
    Dim Temp As String, I As Integer, n As Integer
    n = Len(S)
    For I = n To 1 Step -1
        Temp = Temp & Mid(S, I, 1)
    Next I
    reverse = Temp & Right(S, Len(S) - n)
End Function






Then use the new Excel function:

=reverse(cell2)


For example:




This came from:

Post a Comment

Blog Archive