Solved

Function to reverse text in Excel

Posted on 2007-03-25
4
6,016 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
  • 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 80

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now