A family of Microsoft word processing software products for creating web, email, and print documents.
Hello Steve8d,
Thanks for contacting us. I am glad to help you with your request. You can use VBA to reverse the order of the words in a string. Here's an example of how to do this for your specific example:
Sub ReverseWords() Dim str As String Dim words() As String Dim i As Long
' Change this string to the text you want to reverse str = "From $14,000 1550"
' Split the string into an array of words words = Split(str, " ")
' Reverse the order of the words in the array For i = 0 To UBound(words) / 2 Dim temp As String temp = words(i) words(i) = words(UBound(words) - i) words(UBound(words) - i) = temp Next i
' Join the array of words back into a single string str = Join(words, " ")
' Print the reversed string to the Immediate window Debug.Print str End Sub
In this example, the string "From $14,000 1550" is first split into an array of words using the Split function. Then, a For loop is used to reverse the order of the words in the array. Finally, the Join function is used to join the array of words back into a single string. The reversed string is then printed to the Immediate window using the Debug.Print statement.
You can modify this code to reverse the order of the words in any string by changing the value of the str variable to the text you want to reverse.
Regards, Akande