ranges with dynamic lengths

beng986

Board Regular
Joined
Jan 10, 2012
Messages
88
Hi,

I have two questions both around creating a range with a dynamic length.

In cell A2 I have a input column with the number 6 in it. This represents 6 people.

In A4 I have =sequence(A2,1,1,1), giving me a list of 1 to 6. In B4 I have, =MROUND(RANDARRAY(A2,1,5000,100000,TRUE),5000). This gives me each persons theoretical salary.

However in C4 I want to give them a label of 30,60,90,120, how would I do this, whilst keeping the sheet dynamic? In the same way I want to give them a text label and keep it dynamic so that if the number in A2 was changed all the ranges would as well.

thanks
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You haven't said how you would allocate 30,60,90,120, but maybe
+Fluff v2.xlsm
ABCD
1
26
3
41500009090
52600009090
63400006060
7490000120120
85200003030
9680000120120
Main
Cell Formulas
RangeFormula
A4:A9A4=SEQUENCE(A2,1,1,1)
B4:B9B4=MROUND(RANDARRAY(A2,1,5000,100000,TRUE),5000)
C4:C9C4=IF(B4#<25000,30,IF(B4#<50000,60,IF(B4#<75000,90,120)))
D4:D9D4=LOOKUP(B4#,{0,25000,50000,75000},{30,60,90,120})
Dynamic array formulas.
 
Upvote 0
This is just about creating some random data. It would be amazing to weight the 30,60,90,120,180 to 50%,30%,10%,5%,5%. is that possible?
 
Upvote 0
I've no idea, as I don't understand what you are trying to do.
What are the rules for deciding which value a cell gets?
 
Upvote 0
I am trying to create some quasi random data. In this case there are 6 people to create data for.

A4 is the numbers 1 to 6 representing each person
B4 is the salary of each person rounded to the nearest 5,000
D4 would be an ID, eg EMP001, EMP002
E4 would be how often they are paid e.g every 30 days, 60 days etc. Of course most people are paid every 30 days so I am trying to weight it to the 30 days
 
Upvote 0
For col D use
Excel Formula:
="EMP"&TEXT(A4#,"000")
Please explain exactly what you want for col E.
 
Upvote 0
Thanks. Haven't seen the use of # before. Really useful.

Invoice NumberEmployee nameAmountPayment period
1EMP00180,00060
2EMP00290,00090
3EMP00345,000180
4EMP00430,000180
5EMP00510,00030
6EMP00625,000120

I am looking to create the above. I am currently using =CHOOSE(RANDBETWEEN(1,5),30,60,90,120,180) to generate the payment period. Firstly I would like to make this dynamic as you have done above.

I would also like to, if possible, weight the outcomes to the below

3050%
6025%
9015%
1205%
1805%
 
Upvote 0
You could replace your formula with
Excel Formula:
=CHOOSE(RANDARRAY(A2,,1,5,1),30,60,90,120,180)
or to weight it
Excel Formula:
=LOOKUP(RANDARRAY(A2,,1,100,1),{0,50,75,90,95},{30,60,90,120,180})
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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