• Enter positive number & have return as negative

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Enter positive number & have return as negative

    Author
    Topic
    #479808

    Can anyone help me on this item. I thought it would be easy but so far not.

    I want to format cells that I enter (currency) positive numbers into but they are then returned with the negative format of Brackets & red.

    Anyone offer some ifo.

    Thanks

    Ed

    Viewing 2 reply threads
    Author
    Replies
    • #1304839

      Ed,

      Place the following code in the Worksheet VBA module for the the sheet you want it to operate on.

      Code:
      Option Explicit
      
      Private Sub Worksheet_Change(ByVal Target As Range)
      
      ‘*** Limiting the Worksheet_Change event to a firing when a single cell is changed
      
         Dim isect As Range
         
         Set isect = Application.Intersect(Range(“A:A”), Target)
         If isect Is Nothing Then
      ‘     MsgBox “Ranges do not intersect”  ‘*** Debugging Statement un-comment to use.
         Else
                Target.Formula = Target.Value * -1
         End If
      
      End Sub

      Note: The Range(“A:A”) will cause this macro to operate on all cells in column A. If you need it in a different column adjust as necessary, likewise if you need it in more than one column or you can make a specific range like B7:B23 or B7:H32, etc. :cheers

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1304841

        Thanks. I was almost sure there wasn’t a way to do this

        Ed

    • #1304845

      If it’s only the format you are worried about, you can do that with a custom number format, though it will not change the stored values.

      • #1304858

        Thanks, I need the sum values to be copied into another cell & need the number to reflect that it is negative. When I use custom nuber format I don’t have the facility to actually add it up to be a negative number. Unless there is a custom format to define negative.

        Ed

    • #1304861

      That’s easy enough – just change the other formula from =SUM(…) to =-SUM(…)

      • #1304867

        Hey thanks this is great.

        Ed

      • #1304869

        That’s easy enough – just change the other formula from =SUM(…) to =-SUM(…)

        Nice trick, but I’ve sat in too many meetings where there is someone adding up the column just to be sure, or a wise guy, and this won’t look right. “I’m just sayin’ YMMV” :rolleyes: :cheers:

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

    Viewing 2 reply threads
    Reply To: Enter positive number & have return as negative

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: