+ Reply to Thread
Results 1 to 5 of 5

Simple iteration problem

  1. #1

    Simple iteration problem

    This is something else I desperately need help with at work, but just
    can not figure it out. I THINK it is an iteration problem, but I am not
    sure:

    Cells A1:A500 contain numbers, all of them 5 or 6 figures.
    Cell A501 contains the total of all those numbers, a simple autosum.

    Cell B1 contains a number.

    The problem:

    When you enter a number in B1, all of the numbers in A1:A500 are
    increased or decreased by the same amount, so that A501 = B1.

    If it helps, these are all positive numbers (dollar amounts), and the
    increments and decrements will be very small, maybe a few hundred or a
    thousand dollars or so. None of them will fly off into the negatives or
    anything like that.

    I am thinking of it taking the total of the current numbers and finding
    the difference between that and the amount in B1. Then take that
    difference and add or subtract it from the numbers in A1:A500...
    something like that. But I just can not seem to nail it.

    Thanks very much,
    Ron M.


  2. #2

    Re: Simple iteration problem

    Sorry, I forgot to include something. I apologize:

    The "adjusted" amounts need to appear in another column. Say the number
    in B1 can be in C1 instead. The "adjusted" amounts of the numbers in
    A1:A500 need to appear in B1:B500.

    Again, I apologize.

    Thanks,
    Ron M.


    [email protected] wrote:
    > This is something else I desperately need help with at work, but just
    > can not figure it out. I THINK it is an iteration problem, but I am not
    > sure:
    >
    > Cells A1:A500 contain numbers, all of them 5 or 6 figures.
    > Cell A501 contains the total of all those numbers, a simple autosum.
    >
    > Cell B1 contains a number.
    >
    > The problem:
    >
    > When you enter a number in B1, all of the numbers in A1:A500 are
    > increased or decreased by the same amount, so that A501 = B1.
    >
    > If it helps, these are all positive numbers (dollar amounts), and the
    > increments and decrements will be very small, maybe a few hundred or a
    > thousand dollars or so. None of them will fly off into the negatives or
    > anything like that.
    >
    > I am thinking of it taking the total of the current numbers and finding
    > the difference between that and the amount in B1. Then take that
    > difference and add or subtract it from the numbers in A1:A500...
    > something like that. But I just can not seem to nail it.
    >
    > Thanks very much,
    > Ron M.



  3. #3
    Ardus Petus
    Guest

    Re: Simple iteration problem

    In B1, enter:
    =A1+($C$1-SUM($A$1:$A$25))/ROWS($A$1:$A$25)

    See example: http://cjoint.com/?gks6HbAbgZ

    HTH
    --
    AP

    <[email protected]> a écrit dans le message de news:
    [email protected]...
    > Sorry, I forgot to include something. I apologize:
    >
    > The "adjusted" amounts need to appear in another column. Say the number
    > in B1 can be in C1 instead. The "adjusted" amounts of the numbers in
    > A1:A500 need to appear in B1:B500.
    >
    > Again, I apologize.
    >
    > Thanks,
    > Ron M.
    >
    >
    > [email protected] wrote:
    >> This is something else I desperately need help with at work, but just
    >> can not figure it out. I THINK it is an iteration problem, but I am not
    >> sure:
    >>
    >> Cells A1:A500 contain numbers, all of them 5 or 6 figures.
    >> Cell A501 contains the total of all those numbers, a simple autosum.
    >>
    >> Cell B1 contains a number.
    >>
    >> The problem:
    >>
    >> When you enter a number in B1, all of the numbers in A1:A500 are
    >> increased or decreased by the same amount, so that A501 = B1.
    >>
    >> If it helps, these are all positive numbers (dollar amounts), and the
    >> increments and decrements will be very small, maybe a few hundred or a
    >> thousand dollars or so. None of them will fly off into the negatives or
    >> anything like that.
    >>
    >> I am thinking of it taking the total of the current numbers and finding
    >> the difference between that and the amount in B1. Then take that
    >> difference and add or subtract it from the numbers in A1:A500...
    >> something like that. But I just can not seem to nail it.
    >>
    >> Thanks very much,
    >> Ron M.

    >




  4. #4
    Gary''s Student
    Guest

    RE: Simple iteration problem

    Iteration is not needed. Just scale each entry in A1 thru A500 by the ratio
    of B1 to A501:


    Sub summit()
    v = cells(1, "B").Value / cells(501, "A").Value
    For i = 1 To 500
    cells(i, "A").Value = cells(i, "A").Value * v
    Next
    End Sub

    --
    Gary''s Student


    "[email protected]" wrote:

    > This is something else I desperately need help with at work, but just
    > can not figure it out. I THINK it is an iteration problem, but I am not
    > sure:
    >
    > Cells A1:A500 contain numbers, all of them 5 or 6 figures.
    > Cell A501 contains the total of all those numbers, a simple autosum.
    >
    > Cell B1 contains a number.
    >
    > The problem:
    >
    > When you enter a number in B1, all of the numbers in A1:A500 are
    > increased or decreased by the same amount, so that A501 = B1.
    >
    > If it helps, these are all positive numbers (dollar amounts), and the
    > increments and decrements will be very small, maybe a few hundred or a
    > thousand dollars or so. None of them will fly off into the negatives or
    > anything like that.
    >
    > I am thinking of it taking the total of the current numbers and finding
    > the difference between that and the amount in B1. Then take that
    > difference and add or subtract it from the numbers in A1:A500...
    > something like that. But I just can not seem to nail it.
    >
    > Thanks very much,
    > Ron M.
    >
    >


  5. #5
    Gary''s Student
    Guest

    Re: Simple iteration problem

    If you want the results in another column, say column D then:

    Sub summit()
    v = cells(1, "B").Value / cells(501, "A").Value
    For i = 1 To 500
    cells(i, "D").Value = cells(i, "A").Value * v
    Next
    End Sub

    and the cells in column A will not be over-written
    --
    Gary''s Student


    "[email protected]" wrote:

    > Sorry, I forgot to include something. I apologize:
    >
    > The "adjusted" amounts need to appear in another column. Say the number
    > in B1 can be in C1 instead. The "adjusted" amounts of the numbers in
    > A1:A500 need to appear in B1:B500.
    >
    > Again, I apologize.
    >
    > Thanks,
    > Ron M.
    >
    >
    > [email protected] wrote:
    > > This is something else I desperately need help with at work, but just
    > > can not figure it out. I THINK it is an iteration problem, but I am not
    > > sure:
    > >
    > > Cells A1:A500 contain numbers, all of them 5 or 6 figures.
    > > Cell A501 contains the total of all those numbers, a simple autosum.
    > >
    > > Cell B1 contains a number.
    > >
    > > The problem:
    > >
    > > When you enter a number in B1, all of the numbers in A1:A500 are
    > > increased or decreased by the same amount, so that A501 = B1.
    > >
    > > If it helps, these are all positive numbers (dollar amounts), and the
    > > increments and decrements will be very small, maybe a few hundred or a
    > > thousand dollars or so. None of them will fly off into the negatives or
    > > anything like that.
    > >
    > > I am thinking of it taking the total of the current numbers and finding
    > > the difference between that and the amount in B1. Then take that
    > > difference and add or subtract it from the numbers in A1:A500...
    > > something like that. But I just can not seem to nail it.
    > >
    > > Thanks very much,
    > > Ron M.

    >
    >


+ 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