Consulting

Results 1 to 4 of 4

Thread: Solved: How do you convert negative number to positive?

  1. #1

    Solved: How do you convert negative number to positive?

    My columns F:S has negative numbers, I want to convert it into positive number. How will I do it in such a way that I don't have to manually type -() in every cell?

    Thanks!
    Last edited by mdmackillop; 07-09-2010 at 12:47 AM. Reason: Title corrected

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Your question does not match the title, but to answer the question

    [vba]Dim cel As Range
    For Each cel In Columns("F:S").SpecialCells(xlCellTypeConstants, 1)
    cel.Value = Abs(cel)
    Next
    [/vba]

    Edit: Are your negatives the result of calculated cells?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Find a free cell and type -1 in it. Copy that cell.

    Then select all of the numbers that you want to convert, goto Edit>PasteSpecial... and in the Operation section select the Multiply button.

    OK out, then clear that cell with the -1.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Ooopppsss, missed that! Sorry!

    But anyway, Hi again Mdmckillop!

    Thanks for the code!!!

    and xld, thanks again for the 1 millionth help you gave me! I'll try that, but mdmckillop's code fits lazy people(like me) better!

    mwah! mwah! mwah!

Posting Permissions

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