OzGrid

Excel: Reverse Cell Text/Content

< Back to Search results

 Category: [Excel]  Demo Available 

Excel: Reverse Cell Text/Content

 

Got any Excel/VBA Questions? Free Excel Help

This UDF will reverse the content of any cell

The Code

Function ReverseCell(Rcell As Range, Optional IsText As Boolean)

	Dim i As Integer

	Dim StrNewNum As String

	Dim strOld As String



	strOld = Trim(Rcell)



	For i = 1 To Len(strOld)

		StrNewNum = Mid(strOld, i, 1) & StrNewNum

	Next i

    

	If IsText = False Then

		ReverseCell = CLng(StrNewNum)

	Else

		ReverseCell = StrNewNum

	End If

End Function

To use this UDF push Alt+F11 and go Insert>Module and paste in the code. Push Alt+Q and save. The Function will appear under "User Defined" in the Paste Function dialog box (Shift+F3). 

Enter the function like this for text:

=Reversecell(A1,TRUE)

Or either of the ways below for numeric data

=Reversecell(A1,FALSE)
=Reversecell(A1)

See also:

Excel: Remove Duplicates in Excel
Restricting Excel VBA Loops
Return Excel Color Index Number or Color as Text
Return an Excel Worksheet/Sheet Name to a Cell

 

See also Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions.

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)