Excel UDF: How to Get All words in Reverse Order from a String
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.
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
My name is Vishwamitra Mishra. Friends Call me Vishwa. This blog is authored by me. I am an Excel Geek. Well, this blog talks a lot about my passion in Excels & Macros so I’ll not talk about it :) I am very much passionate about traveling & quite recently discovered that I am a good photographer too..:P
AND GET A FREE!
E-BOOK FOR EXCEL VBA BEGINNERS
DON'T MISS ANY NEW ARTICLE !
Get your FREE! E-Book & Have Every New Article Delivered Straight To Your Email-Box