How to Reverse a String in Excel (3 Suitable Ways)

When files are imported into Excel, words can occasionally be flipped. In order to produce meaningful terms, we must reverse those strings. In this post, we’ve covered a variety of simple ways on how to reverse a string in Excel. So, continue with us and follow the procedure.

Despite the lack of any built-in function, there are several methods for doing this. At first, we will do reversing string with functions and then we will continue with VBA code.


1. Using MID and CONCATENATE Functions to Reverse a String in Excel

Follow these steps to flip the string “ExcelDemy” in cell B4:

📌 Steps:

  • We will enter the following formula in cell C4:
=MID($B$4,LEN($B$4)-ROW(B4)+4,1)
  • So, the letter “y” should be returned as it is the last character in the provided string.

Using MID and CONCATENATE Functions to Reverse a String in Excel

  • So now, drag the fill handle downward identical to the picture that is situated at the bottom right of cell C4.

  • We will enter the TRANSPOSE function in the cell that follows the final cell of column C, or cell C12, then drag and select cells C4 through C12 before closing the parentheses around the TRANSPOSE formula.

Enter the TRANSPOSE Function and Press F9 to get the output

  • Now we will press F9 after selecting the entire formula in the formula bar. Then the formula bar will be like this:
={"y","m","e","D","l","e","c","x","E"} 
  • As our main purpose is to use the CONCATENATE function, we will use this function after replacing the first curly brace and removing the second curly brace with the second parenthesis. Now this will turn into “ExcelDemy” to “ymeDlecxE”.

Apply CONCATENATE Function


2. Reversing a String with MID and TEXTJOIN Functions

In the previous method, we merged by CONCATENATE function but in this method, we will use TEXTJOIN. These two functions both do the same task but TEXTJOIN can add a delimiter between strings.

📌 Steps:

  • Insert the following formula in cell C4 and drag the fill handle to the last cell.
=TEXTJOIN("",1,MID(B4,{20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1},1))
  • The main purpose of this formula is to reverse strings like reversing the order of numbers in the array and the MID function returns a single character for each number in the array. And lastly, TEXTJOIN joins those strings in reverse order.

Apply TEXTJOIN and MID functions to reverse string in excel

💬 Note:

Only text with 20 characters or fewer than 20 characters can be used in this formula. But for longer strings, you have to use the VBA code given below.


3. Applying VBA Code to Reverse a String in Excel

Now we can easily flip a string by VBA code. In this method, we have to write the code or copy it from here.

3.1 Apply VBA Code to a Single Cell

  • By selecting the string that we want to reverse, we will press ALT+F11. Then the VBA window will appear. Now we will copy the following string and paste it in the window. 
Sub Reverse_String()
Dim s As Range
Set s = Application.Selection
s.Offset(0, 1).Value = StrReverse(s)
End Sub
  • Now we will press F5 to run the VBA code. Consequently, the result shown in the worksheet will be like “ymeDlecxE”.

ALT+F11 and opening VBA window


3.2  Apply VBA Code to Multiple Cells

Already, using VBA code, we have flipped a string with ease. This method’s code is for several strings that must be composed or copied from here.

📌 Steps:

  • Picking the strings that we wish to reverse and tapping ALT+F11, the VBA window will appear. Following that, we’ll copy the following VBA code and paste it into the window. To run the code press F5.
Sub reverse_string_range()
Dim s As Range
Dim cell As Range
Set s = Application.Selection
i = 0
For Each cell In s
cell.Offset(0, 1).Value = StrReverse(cell)
i = i + 1
Next cell
End Sub

Apply VBA Code for Multiple Cells: how to reverse a string in excel

Read More: How to Use Excel VBA to Reverse String


Download Practice Workbook

You can download the practice workbook from the following download button.


Conclusion

To Reverse a String in Excel, follow these procedures and stages. You may download the workbook and use it for your own practice as well. In the comments area, if you have any questions, issues, or recommendations, just let me know.


Related Articles


<< Go Back to Excel Reverse Order | Sort in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Al Ikram Amit
Al Ikram Amit

Al Ikram Amit, holding a BSc in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, serves as a key Excel & VBA Content Developer at ExcelDemy. Driven by a profound passion for research and innovation, he actively immerses himself in Excel. In his role, Amit not only skillfully addresses complex challenges but also exhibits enthusiasm and expertise in gracefully navigating tough situations, emphasizing his steadfast commitment to consistently delivering exceptional, high-quality content that adds significant... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo