+ Reply to Thread
Results 1 to 2 of 2

Looping and inserting negaive totals

  1. #1
    Jim May
    Guest

    Looping and inserting negaive totals

    How would I code a macro to have it -sum()
    Afterwards Col E should total 0.00
    In Cell
    E426 -754.05
    E422 -5,409.85 << I have several groups like this between Row 6 and
    427
    E420 -13,397.65
    E418 -4,132.69
    E6 -60.00

    I've been trying to alter similar code, but without success.
    Thanks in Advance..

    Row# Col E
    6
    7 60.00
    .....
    418
    419 4132.69
    420
    421 13397.65
    422
    423 2365.13
    424 1522.36
    425 1522.36
    426
    427 754.05


  2. #2
    Tom Ogilvy
    Guest

    RE: Looping and inserting negaive totals

    Sub MakeNegatives()
    Dim lastrow as Long, i as Long
    Dim sm as double
    lastrow = cells(rows.count,"E").End(xlup).Row
    for i = lastrow to 6 step - 1
    if not isempty(cells(i,"E")) then
    sm = sm + cells(i,"E")
    else
    cells(i,"E").Value = -1 * sm
    sm = 0
    end if
    Next
    End Sub


    Untested, but this should get you started.
    --
    Regards,
    Tom Ogilvy


    "Jim May" wrote:

    > How would I code a macro to have it -sum()
    > Afterwards Col E should total 0.00
    > In Cell
    > E426 -754.05
    > E422 -5,409.85 << I have several groups like this between Row 6 and
    > 427
    > E420 -13,397.65
    > E418 -4,132.69
    > E6 -60.00
    >
    > I've been trying to alter similar code, but without success.
    > Thanks in Advance..
    >
    > Row# Col E
    > 6
    > 7 60.00
    > .....
    > 418
    > 419 4132.69
    > 420
    > 421 13397.65
    > 422
    > 423 2365.13
    > 424 1522.36
    > 425 1522.36
    > 426
    > 427 754.05
    >
    >


+ 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