I created this UDF (User defined Function) to help you in arranging all the Words of a String in Reverse Order. It will put the Words in a reverse Order. Letters of each words will remain in same (proper) order.
If you want to reverse the whole String then
refer this Article.
Put the below code inside your Regular Module. Then you can use this Formula anywhere in your Workbook.
Syntax:
=ReverseWords(Cell Address)
Public Function ReverseWords(cell As Range)
Dim InputStr As String
Dim InputArray() As String
Dim OutputArray As String
Dim WordsCount As Integer
InputStr = cell.Value
'Split all the words and put it
'in an array
InputArray = Split(InputStr, " ")
WordsCount = UBound(InputArray)
'Read all the words in reverse
'Order and return to function
For i = WordsCount To 0 Step -1
ReverseWords = ReverseWords & InputArray(i) & " "
Next
End Function
0 Comments