VBA – Reverse words in a sentence

Reversing words in a sentence with VBA in Excel is quite easy, using the built-in StrReverse function.

StrReverse takes a string and reverses it. Thus, “VitoshAcademy.com” becomes “moc.ymedacAhsotiV”:

The idea of reversing the order of the words in a sentence needs a couple of more steps :

  • reversing the sentence once
  • splitting the reversed words to an array
  • writing down the words and reversing them one by one

Quite an easy and straight forward algorithm, once you know it.

Tagged with: , , , ,