Divide number beetwen cells

Pontos

Board Regular
Joined
Mar 26, 2003
Messages
132
Hi.

I want to equaly divide number which is in cell E4 on range (A1:B80). How can I do that?
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Do you mean that the area A1:B80 is currently blank, and you want a formula in those cells to get 1/160th of E4 in each cell?
 
Upvote 0
Try this:

Code:
Function Distribute(SourceCell As Range)
    Dim V() As Variant
    myrows = Selection.Rows.Count
    mycols = Selection.Columns.Count
    ReDim V(1 To myrows, 1 To mycols)
    For R = 1 To myrows
        For C = 1 To mycols
            V(R, C) = SourceCell.Value / Selection.Count
        Next
    Next
    Distribute = V
End Function

Select the entire range you want, then type =Distribute(E4), and press Ctrl+Shift+Enter
 
Upvote 0
The function I gave above will not remember the selection and will change its results whenever the selection changes.

This function fixes that problem:

Code:
Function Distribute(SourceCell As Range, OutputRange As Range)
    Dim V() As Variant
    myrows = OutputRange.Rows.Count
    mycols = OutputRange.Columns.Count
    ReDim V(1 To myrows, 1 To mycols)
    For R = 1 To myrows
        For C = 1 To mycols
            V(R, C) = SourceCell.Value / OutputRange.Count
        Next
    Next
    Distribute = V
End Function

You may use it like this: Select the entire range you want (e.g. A1:B80), then type =Distribute(E4, A1:B80), and press Ctrl+Shift+Enter
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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