Excel VBA

css navigation by Css3Menu.com

Move Minus (Revisited)

We have a text file from SAP that brings over 28,000 rows of information. The minus is on the wrong end for Excel AND commas are already part of the number.
Private Sub FixNegativeValues()
    'Move negative sign from back to front
    range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select  'Select all cells
    For Each cel In Selection.Cells
        On Error Resume Next	'Handle errors
        If Right(cel.Text, 1) = "-" Then
            cel.Value = Round(CCur(cel.Text), 2)
        End If
      On Error Goto 0
End Sub

The TRIM statement gets rid of the extraneous junk that was messing with the numbers.

© 2003-2024

Updated:  04/17/2024 12:26
This page added:  12 September 2003