?
Solved

Function to reverse text in Excel

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
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…

762 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