by Allen Wyatt
(last updated June 25, 2018)
VBA includes some very powerful commands and functions for manipulating strings. One such function allows you to easily reverse the contents of a string: the StrReverse function. All you need to do is to pass it a string value, and it returns the reversed version of the string:
Dim MyString As String Dim BackString As String MyString = "ABCD1234" BackString = StrReverse(MyString)
When the code snippet is through executing, the value of the BackString variable is set to 4321DCBA, which is the reverse of the original value of the MyString variable.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11514) applies to Microsoft Word 2007, 2010, 2013, and 2016.
Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!
When creating macros, you might want to know if a user has made changes in the document or not. Here's how to figure that ...Discover More
If you write a macro that makes changes to a document, you may want that macro to save those changes. There are several ...Discover More
One of the basic programming structures used in VBA is the While ... Wend structure. This structure helps to make the ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.