Solved

Function to reverse text in Excel

Posted on 2007-03-25
4
6,036 Views
Last Modified: 2012-05-05
Is it possible to create a function that reverses the text in a cell in Excel? For example, could I create a user defined function called, say, Reversetext which would reverse the text in a specific cell. e.g. If 'hello' was in cell A1 and the function in B1 was Reversetext(A1), B1 would display 'olleH'.

Or perhaps there is an easier way than a UDF? I can do it with string manipulation using standard excel functions, but that is rather laborious.

Thanks

0
Comment
Question by:Terrygordon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
Steve Dubyo earned 250 total points
ID: 18788340
You can use this function to reverse text..

Function Reverse(Text as String) as String
      Dim i As Integer
      Dim StrNew As String
      Dim strOld As String

      strOld = Trim(Text)

      For i = 1 To Len(strOld)
            StrNew = Mid(strOld, i, 1) & StrNew
      Next i

      Reverse = StrNew
      
End Function
0
 

Author Comment

by:Terrygordon
ID: 18788667
Thanks Influenz. Spot on!
0
 
LVL 81

Expert Comment

by:byundt
ID: 18789264
I recognize that the question has already been closed, but there is actually a string reverse capability built into VBA:

Function Reverse(Text as String) as String
Reverse = StrReverse(Text)
End Function
0
 
LVL 5

Expert Comment

by:Steve Dubyo
ID: 18789337
thanks for that byundt, i hadnt noticed that.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question