+ Reply to Thread
Results 1 to 5 of 5

Ending Negative Sign

  1. #1
    Forum Contributor
    Join Date
    04-25-2006
    Posts
    215

    Ending Negative Sign

    I have figures that I copy and paste from AS400 into an Excel worksheet. The figures get pasted as text with a minus sign after the number for negative values: 2340-. I need to convert these numbers to <2340> format.

    I simply need a formula that says if this range has values with "-" at the end of the number, then format <xxxx>, otherwise format as +xxxx.

    Thanks.

    ep

  2. #2
    arno
    Guest

    Re: Ending Negative Sign

    hi,

    try to convince sbd. to bring the - sign on the other side.

    otherwise, that'll do:

    =if(right(a1,1)="-", -value(left(a1, len(a1)-1)), value(a1))

    arno

  3. #3
    Forum Contributor
    Join Date
    04-25-2006
    Posts
    215

    It works, but..

    It works, but not quite as I need it to. I would like the formula to refer to a range of cells - for example A1:A10. When data is entered into these cells, it automatically converts the data to the correct format (In the same cell that the data was entered).

    Thanks again.

    ep

  4. #4
    Bob Phillips
    Guest

    Re: Ending Negative Sign

    Private Sub Worksheet_Change(ByVal Target As Range)
    Const WS_RANGE As String = "A1:A10"
    Dim cell As Range

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    For Each cell In Target
    If Right(cell.Value, 1) = "-" Then
    cell.Value = Left(cell.Value, Len(cell.Value) - 1) * -1
    cell.NumberFormat = "0;<0>"
    End If
    Next cell
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.



    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "edwardpestian" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > It works, but not quite as I need it to. I would like the formula to
    > refer to a range of cells - for example A1:A10. When data is entered
    > into these cells, it automatically converts the data to the correct
    > format (In the same cell that the data was entered).
    >
    > Thanks again.
    >
    > ep
    >
    >
    > --
    > edwardpestian
    > ------------------------------------------------------------------------
    > edwardpestian's Profile:

    http://www.excelforum.com/member.php...o&userid=33809
    > View this thread: http://www.excelforum.com/showthread...hreadid=556349
    >




  5. #5
    Forum Contributor
    Join Date
    04-25-2006
    Posts
    215

    Works Great!

    Thanks Bob.

    ep

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1