KlayontKress
Board Regular
- Joined
- Jan 20, 2016
- Messages
- 67
- Office Version
- 2016
- Platform
- Windows
To all,
I'm looking for a macro that will allow the user to select multiple cells (up to 5) in a row (Lets say E10 and G10) and then add the sum of those two cells into the left most cell selected (this will usually be the first cell selected but it's possible the user will select the calues in a different order than left to right (we can standardize if we need to)).
I then need the macro to go through and repeat this for every row in a column with values use the same relative positions as the first series of values selected.
For example, from the chart below, lets say I select D4, E4,G4,M4. I want to placed the summed value of these into cell D4 (not the formula for the sum but the actual value). In this case it would be 23. I then need the macro to remember that the left most column is "D" and that the initial values selected were in relative positions of +0, 1, 3, and 9 to go through and do this same calculation for every row in column D with a value and put in the summed value. The macro would then deleted all of the columns for the values selected except for the left most one where the summed values went.
The values in column "D" would end up being:
D4=23
D6=27
D8=31
D10=35
D12=39
and columns E,G, and M in the column below would be deleted.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]group[/TD]
[TD]style[/TD]
[TD][/TD]
[TD]Room 1[/TD]
[TD]Room 2[/TD]
[TD]Room 3[/TD]
[TD]Room 4[/TD]
[TD]Room 5[/TD]
[TD]Room 6[/TD]
[TD]Room 7[/TD]
[TD]Room 8[/TD]
[TD]Room 9[/TD]
[TD]Room 10[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]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TD]9[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]level 3[/TD]
[TD]blah blah blah blah[/TD]
[TD][/TD]
[TD]13[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]level 4[/TD]
[TD]blaah[/TD]
[TD][/TD]
[TD]14[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]12[/TD]
[TD]13[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thanks for your help,
I'm looking for a macro that will allow the user to select multiple cells (up to 5) in a row (Lets say E10 and G10) and then add the sum of those two cells into the left most cell selected (this will usually be the first cell selected but it's possible the user will select the calues in a different order than left to right (we can standardize if we need to)).
I then need the macro to go through and repeat this for every row in a column with values use the same relative positions as the first series of values selected.
For example, from the chart below, lets say I select D4, E4,G4,M4. I want to placed the summed value of these into cell D4 (not the formula for the sum but the actual value). In this case it would be 23. I then need the macro to remember that the left most column is "D" and that the initial values selected were in relative positions of +0, 1, 3, and 9 to go through and do this same calculation for every row in column D with a value and put in the summed value. The macro would then deleted all of the columns for the values selected except for the left most one where the summed values went.
The values in column "D" would end up being:
D4=23
D6=27
D8=31
D10=35
D12=39
and columns E,G, and M in the column below would be deleted.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]group[/TD]
[TD]style[/TD]
[TD][/TD]
[TD]Room 1[/TD]
[TD]Room 2[/TD]
[TD]Room 3[/TD]
[TD]Room 4[/TD]
[TD]Room 5[/TD]
[TD]Room 6[/TD]
[TD]Room 7[/TD]
[TD]Room 8[/TD]
[TD]Room 9[/TD]
[TD]Room 10[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]base[/TD]
[TD]blah[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
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]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]level 4[/TD]
[TD]blaah[/TD]
[TD][/TD]
[TD]14[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]12[/TD]
[TD]13[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thanks for your help,
Last edited: