Solved

Function to reverse text in Excel

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

914 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

17 Experts available now in Live!

Get 1:1 Help Now