Userdefined Function / Formulae

JayModi

New Member
Joined
Jul 5, 2010
Messages
8
Dear Excel Experts-

We use SAP system and whenever I copy any data (from SAP) and paste it to excel, it paste it in following format (which is incompatible to sum):

1,468.98
29,463.83
2,281.10-
12,684.40-
64,254.04-

So this causes us manually to change it to:

1,468.98
29,463.83
-2,281.10
-12,684.40
-64,254.04

Is there a way I can write a formulae or function in VBA which will automatically change the 64,254.04- to -64,254.04 and leave the postive ones as it is? If there is something like that than I would really apprecite if you can provide the VBA code (procedure).

Thank You in advance.
Jay
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Tinbendr

Well-known Member
Joined
Jul 21, 2010
Messages
997
We use SAP system
My condolences.

Try this.
Code:
Sub ChangeSigns()
Dim A As Long
Dim ColNum As Long
'Cursor must be in column in question.
ColNum = ActiveCell.Column

With ActiveSheet
    LastRow = .Cells(.Rows.Count, ColNum).End(xlUp).Row
    For A = 1 To LastRow
        If Right(.Cells(A, ColNum).Value, 1) = "-" Then
            .Cells(A, ColNum).Value = _
                Left(.Cells(A, ColNum).Value, _
                Len(.Cells(A, ColNum).Value) - 1) * -1
        End If
    Next
End With
End Sub
My ZAP doesn't produce any negative numbers in my work, but assuming they get translated as text, this should work.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,752
Office Version
2010
Platform
Windows
You can also select the column and do Data > Text to columns, Finish.
 

Watch MrExcel Video

Forum statistics

Threads
1,101,935
Messages
5,483,776
Members
407,410
Latest member
catherinejoy

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top