Move the sign from the right-hand side thus changing a text string into a value. : Right « String Functions « VBA / Excel / Access / Word






Move the sign from the right-hand side thus changing a text string into a value.

 

Sub MoveMinus()
    On Error Resume Next
    Dim cel As Range
    Dim myVar As Range
    Set myVar = Selection
   
    For Each cel In myVar
        If Right((Trim(cel)), 1) = "-" Then
            cel.Value = cel.Value * 1
        End If
    Next
End Sub

 








Related examples in the same category

1.Right() Returns a substring from the right side of a string.