Macro to fill in a number of cells based on a specific value

MaxTiger

New Member
Joined
Nov 19, 2018
Messages
4
Hi all,


I am looking for a macro that can fill in a number of cells based on a specific value. For instance, a row is populated with 0's & 1's from lets say column A to N which cumalatives to 8. I want to extend this row until column Z by adding "X" to reach a cummulative of 17. That means that (without changing the values from A to N), there are 12 remaning cells until column Z is reached, to to add 9 to the cummulative. However, I want these values to be spread evenly accros the remaining 12 cells, and only integer.


This spread must be with the following patern, rounding up to the closest whole number returns a 1 or a 0:
[TABLE="width: 500"]
<tbody>[TR]
[TD]0.75
[/TD]
[TD]1.5
[/TD]
[TD]2.25
[/TD]
[TD]3
[/TD]
[TD]3.75
[/TD]
[TD]4.5
[/TD]
[TD]5.25
[/TD]
[TD]6
[/TD]
[TD]6.75
[/TD]
[TD]7.5
[/TD]
[TD]8.25
[/TD]
[TD]9
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]0
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]0
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]0
[/TD]
[TD]1
[/TD]
[/TR]
</tbody>[/TABLE]


For each set from A to Z I wan to do the same. The next set AA to AZ has no values yet, because as stated before, only cells in columns A to N were populated. Again, i want to be able to insert an "X value" that would determine the spread and cumulative of that 'set'.


So finally you would have the possibility to insert an X for A to Z, AA to AZ, BA to BZ and so on.
I am not sure if this is even posible with macros or formulas, but I hope one of you could give me a solution to this!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
With a blank column at left,

[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][td="bgcolor:#C0C0C0"]
C​
[/td][td="bgcolor:#C0C0C0"]
D​
[/td][td="bgcolor:#C0C0C0"]
E​
[/td][td="bgcolor:#C0C0C0"]
F​
[/td][td="bgcolor:#C0C0C0"]
G​
[/td][td="bgcolor:#C0C0C0"]
H​
[/td][td="bgcolor:#C0C0C0"]
I​
[/td][td="bgcolor:#C0C0C0"]
J​
[/td][td="bgcolor:#C0C0C0"]
K​
[/td][td="bgcolor:#C0C0C0"]
L​
[/td][td="bgcolor:#C0C0C0"]
M​
[/td][td="bgcolor:#C0C0C0"]
N​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td][/td][td]
0.75​
[/td][td]
1.5​
[/td][td]
2.25​
[/td][td]
3​
[/td][td]
3.75​
[/td][td]
4.5​
[/td][td]
5.25​
[/td][td]
6​
[/td][td]
6.75​
[/td][td]
7.5​
[/td][td]
8.25​
[/td][td]
9​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td][/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
0​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
0​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]
0​
[/td][td="bgcolor:#CCFFCC"]
1​
[/td][td="bgcolor:#CCFFCC"]B2: =ROUND(B1, 0) - SUM($A2:A2)[/td][/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top