Monday, July 15, 2013

Excel Macro VBA suffix minus sign to become prefix

Sub RemoveMinus()
'Purpose: Move the minus sign suffix on a number to the front.
'Example: 235- become -235

Dim rngStep As Range
On Error Resume Next
    For Each rngStep In ActiveSheet.UsedRange
        If Right(rngStep.Value, 1) = "-" Then
            rngStep.Value = "-" & Mid(rngStep.Value, 1, Len(rngStep.Value) - 1)
        End If
    Next
On Error GoTo 0
End Sub

No comments:

Post a Comment