+ Reply to Thread
Results 1 to 3 of 3

Change Number to a negative in VBA

  1. #1
    Noemi
    Guest

    Change Number to a negative in VBA

    Hi
    I currently have a range of numbers which need to be change from a positive
    into a negative however I am not aware of the cell reference as the rows can
    be more or less.

    Does anyone know how to change a range of numbers from a positive into a
    negative using VBA.

    I actually need the number to be negative not just the format.

    Thanks
    Noemi

  2. #2
    Gord Dibben
    Guest

    Re: Change Number to a negative in VBA

    Noemi

    If numbers are in Activecell column..........

    Sub test()
    Dim rcel As Range
    Dim Rng As Range
    Set Rng = Range(ActiveCell, Cells(Rows.Count, _
    ActiveCell.Column).End(xlUp))
    For Each rcel In Rng
    If rcel.Value <> "" And rcel.Value >= 0 Then
    rcel.Value = rcel.Value * -1
    End If
    Next rcel
    End Sub


    Gord Dibben Excel MVP

    On Mon, 21 Nov 2005 21:16:02 -0800, "Noemi" <[email protected]>
    wrote:

    >Hi
    >I currently have a range of numbers which need to be change from a positive
    >into a negative however I am not aware of the cell reference as the rows can
    >be more or less.
    >
    >Does anyone know how to change a range of numbers from a positive into a
    >negative using VBA.
    >
    >I actually need the number to be negative not just the format.
    >
    >Thanks
    >Noemi



  3. #3
    Jerry W. Lewis
    Guest

    Re: Change Number to a negative in VBA

    VBA is not required for this. Put -1 in an empty cell. Copy that cell.
    Select the range of numbers whose sign you want to change. Edit|Paste
    Special|Multiply.

    Jerry

    Noemi wrote:

    > Hi
    > I currently have a range of numbers which need to be change from a positive
    > into a negative however I am not aware of the cell reference as the rows can
    > be more or less.
    >
    > Does anyone know how to change a range of numbers from a positive into a
    > negative using VBA.
    >
    > I actually need the number to be negative not just the format.
    >
    > Thanks
    > Noemi



+ 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