# Thread: Function to inverse negative values! (Excel 2000 >)

1. ## Function to inverse negative values! (Excel 2000 >)

The code in this UDF will convert inverse negatives ( 34-) to the correct format (-34).:

Function MirrorNegatives(Negative_Value As String) As Double
Dim NewVal As String
If Right(Trim(Negative_Value), 1) = "-" Then
NewVal = Right(Trim(Negative_Value), 1) & Negative_Value
Else
NewVal = Negative_Value
End If
MirrorNegatives = Application.WorksheetFunction.Substitute( _
NewVal, "-", "", 2) + 0
End Function

Copy it to your Workbook or to the personal macro workbook to increase its scope. You can also save it as an Add-In if desired!

2. ## Re: Function to inverse negative values! (Excel 2000 >)

or:<pre>Function MirrorNegatives(Negative_Value As String) As Double
MirrorNegatives = CDbl(Negative_Value)
End Function
</pre>

3. ## Re: Function to inverse negative values! (Excel 2000 >)

Sheez...thats a lot easier. I did not know that CDbl converts to positive. Is this a natural behaviour?

4. ## Re: Function to inverse negative values! (Excel 2000 >)

It doesn't convert to a positive - it coerces the input value to a double. There's obviously something in there that recognizes trailing negatives. Whether you could call that natural depends on your definition! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

5. ## Re: Function to inverse negative values! (Excel 2000 >)

Thanx Rory. Its a great shortcut
<img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

6. ## Re: Function to inverse negative values! (Excel 20

Sounds like you've been having to cope with SAP for quite a long time! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•