Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Function to reverse text in Excel

Posted on 2007-03-25
4
Medium Priority
?
6,061 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 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