Returns the contents of a cell with all the characters reversed.


* For instructions on how to add a function to a workbook refer to the page under Inserting Functions
* The equivalent JavaScript function is REVERSE

'sCellContents - The number or text you want to reverse.

Public Function REVERSE(ByVal sCellContents As String) As String

   If Application.WorksheetFunction.IsNonText(sCellContents) = True Then
      REVERSE = VBA.CVErr(xlCVError.xlErrNA)
      REVERSE = VBA.StrReverse(sCellContents)
   End If

End Function

If the argument is not a number or a text string, then #N/A is returned.
This uses the built-in VBA function STRREVERSE.

microsoft excel docs


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext