{"id":12121,"date":"2012-01-20T05:36:28","date_gmt":"2012-01-20T05:36:28","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=1280"},"modified":"2017-07-01T10:18:55","modified_gmt":"2017-07-01T10:18:55","slug":"words-in-reverse-order","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2012\/01\/words-in-reverse-order\/","title":{"rendered":"Excel UDF: How to Get All words in Reverse Order from a String"},"content":{"rendered":"
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<\/strong> in a reverse Order. Letters of each words will remain in same (proper) order. <\/a><\/p>\n Put the below code inside your Regular Module. Then you can use this Formula anywhere in your Workbook.<\/p>\n Syntax:<\/strong><\/p>\n 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 […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1673,1246,2056],"tags":[],"class_list":["post-12121","post","type-post","status-publish","format-standard","hentry","category-excel-functions","category-macro","category-udf"],"yoast_head":"\n
\nIf you want to reverse the whole String then <\/p>\nrefer this Article.<\/h3>\n
=ReverseWords(Cell Address)<\/h3>\n
\nPublic Function ReverseWords(cell As Range)\n\t\n\tDim InputStr As String\n\tDim InputArray() As String\n\tDim OutputArray As String\n\tDim WordsCount As Integer\n\t\n\tInputStr = cell.Value\n\t\n'Split all the words and put it\n'in an array\n\tInputArray = Split(InputStr, \" \")\n\tWordsCount = UBound(InputArray)\n\t\n'Read all the words in reverse\n'Order and return to function\n\t\n\tFor i = WordsCount To 0 Step -1\n\t\tReverseWords = ReverseWords & InputArray(i) & \" \"\n\tNext\n\t\nEnd Function\n\n<\/code><\/pre>\n<\/span>","protected":false},"excerpt":{"rendered":"