Search code examples
excelformulaincrementradix

Change part of excel formula with a constant value


I have an excel formula across a column for which the base changes every "x" number of rows. Note this "x" is not constant and keeps changing. e.g.

=D1/SUM(D$1:D$4)
=D2/SUM(D$1:D$4)
=D3/SUM(D$1:D$4)
=D4/SUM(D$1:D$4)
=D5/SUM(D$5:D$9)
=D6/SUM(D$5:D$9)
=D7/SUM(D$5:D$9)
=D8/SUM(D$5:D$9)
=D9/SUM(D$5:D$9)

I am trying to change the first part of the formulas without changing the second and vice versa. e.g. changing the numerator by 10 cells.

=D11/SUM(D$1:D$4)
=D12/SUM(D$1:D$4)
=D13/SUM(D$1:D$4)
=D14/SUM(D$1:D$4)
=D15/SUM(D$5:D$9)
=D16/SUM(D$5:D$9)
=D17/SUM(D$5:D$9)
=D18/SUM(D$5:D$9)
=D19/SUM(D$5:D$9)

or, changing the base by 100. e.g.

=D1/SUM(D$100:D$104)
=D2/SUM(D$100:D$104)
=D3/SUM(D$100:D$104)
=D4/SUM(D$100:D$104)
=D5/SUM(D$105:D$109)
=D6/SUM(D$105:D$109)
=D7/SUM(D$105:D$109)
=D8/SUM(D$105:D$109)
=D9/SUM(D$105:D$109)

Sometimes, both. Any guidance on how this can be possible?

Thank you.


Solution

  • the first part of this problem seems easy unless I am missing something?

    Part 1:

    Since the denominator is already in $x form, you can select and COPY the whole range of formulas and PASTE them 10 rows down and then CUT and paste it back into position. The COPY will update the numerators appropriately and when you CUT and PASTE it back into position they will now be just as you want? The second question will be a bit more of a challenge!

    Part 2:

    OK without VBA I can only think of a really long-winded way to change your demoninators, but I just checked that it does work: To change the bottom.

    1. Search and replace = with '=

    Now you can edit the formulas more freely.

    1. Search and replace D with D%

    2. Search and replace D%$ with D

    3. Search and replace D% with D$
    4. get rid of the '= by using the Data>text to columns option
    5. Now use the copy and paste, cut paste trick from part 1.

    Then if you still need your $s back as they were you essentially repeat 1 to 5 again. Sorry, this looks really long-winded, but if you are desperate and back up before you start it should work.