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("D8").Select
    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
    Next
      On Error Goto 0
End Sub

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

© 2003-2024

Updated:  06/21/2024 07:42
This page added:  12 September 2003