Excel: VLOOKUP + randomized data depending on the cell

excelnewbieneedhelp

New Member
Joined
Apr 6, 2018
Messages
3
Hello guys :)

Thanks for viewing my thread, I have some question regarding on using VLOOKUP+randomized data.

Sheet1

<code>branchID

BRANCH01
BRANCH02
BRANCH03
BRANCH04
</code> Sheet2

<code>employeeID

EMPLOYEE01 -- BRANCH01
EMPLOYEE02 -- BRANCH01
EMPLOYEE03 -- BRANCH02
EMPLOYEE04 -- BRANCH02
EMPLOYEE05 -- BRANCH03
EMPLOYEE06 -- BRANCH03
EMPLOYEE07 -- BRANCH04
EMPLOYEE08 -- BRANCH04


What I want for the result -
Sheet3


BRANCHID EMPLOYEEID

</code><code><code>BRANCH01 </code></code><code><code><code>EMPLOYEE01 </code>
<code><code><code><code><code>BRANCH01 EMPLOYEE02
BRANCH03 EMPLOYEE05
BRANCH03 EMPLOYEE06
BRANCH04 EMPLOYEE07
BRANCH01 EMPLOYEE02
BRANCH01 EMPLOYEE01
BRANCH02 EMPLOYEE03

which that the employeeID is depending on branchid (and it will randomized the value between(EMPLOYEE01 & EMPLOYEE02) whenthe branchid is BRANCH01, sames goes to BRANCH02 (EMPLOYEE03 &EMPLOYEE04) , BRANCH03 (EMPLOYEE05 & EMPLOYEE06) , BRANCH04(EMPLOYEE07 & EMPLOYEE08)</code></code></code></code></code></code><code><code><code><code><code>
</code></code></code></code></code>


</code>
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Welcome to the Forum!

Perhaps something like this:

E3: =INDEX($B$2:$B$10,AGGREGATE(15,6,(ROW(B$1:B$10)-ROW(B$1)+1)/(A$2:A$10=D3),RANDBETWEEN(1,COUNTIF(A$2:A$10,D3))))

But as always, it depends what you mean by "random". Perhaps in this case you want each of the employees 11, 33, 44, 77 and 99 to appear once each (i.e. not randomly), but in random order?


Book1
ABCDE
1Branch IDEmployee ID
2A11BranchRandom
3B22A11
4A33A44
5A44A44
6B55A77
7B66A44
8A77
9B88
10A99
Sheet1
 
Last edited:
Upvote 0
Welcome to the Forum!

Perhaps something like this:

E3: =INDEX($B$2:$B$10,AGGREGATE(15,6,(ROW(B$1:B$10)-ROW(B$1)+1)/(A$2:A$10=D3),RANDBETWEEN(1,COUNTIF(A$2:A$10,D3))))

But as always, it depends what you mean by "random". Perhaps in this case you want each of the employees 11, 33, 44, 77 and 99 to appear once each (i.e. not randomly), but in random order?

ABCDE
1Branch IDEmployee ID
2A11BranchRandom
3B22A11
4A33A44
5A44A44
6B55A77
7B66A44
8A77
9B88
10A99

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>

Hello, Thanks for the response :D

sorry I don't think that is what I wanted.

i will explain more with pics ( sorry for poor english , not my main languages )

http://prntscr.com/j22ogn ( BRANCH sheet )

http://prntscr.com/j22oq5 ( Employee sheet)

http://prntscr.com/j22ow3 (Sheet that i need to combine both data (employee and branch) )


in the third picture, I used 'RANDBETWEEN' to random around 400 data between (BRANCH01 to BRANCH04), and I wanted to do the same to my employeeID too , but there is a requirement which that the EMPLOYEEID need to match with the BRANCHID
 
Upvote 0
The solution will depend on exactly what you mean by "random"?

Expanding on my previous example:

D3: =INDEX(A$15:A$17,RANDBETWEEN(1,COUNTA(A$15:A$17)))
randomly selects branch A, B or C from the unique branch list. Note that using this formula A, B and C are equally likely to be selected. Is this OK? Or should we perhaps select Branch A three times as frequently as B or C, given that A has six employees, and B and C each have two employees?

E3: =INDEX($B$2:$B$11,AGGREGATE(15,6,(ROW(B$1:B$11)-ROW(B$1)+1)/(A$2:A$11=D3),RANDBETWEEN(1,COUNTIF(A$2:A$11,D3))))
randomly selects an employee from the randomly selected Branch B. Note that for Branch C, employee 88 has been randomly selected four times, and employee 66 nil times. Is this OK? Or do you want "random" to mean something different?


Book1
ABCDE
1Branch IDEmployee ID
2A11BranchRandom
3B22B22
4A33A11
5A44C88
6B55B22
7C66C88
8A77C88
9C88C88
10A99A11
11A00B55
12B22
13B55
14Unique Branch ID
15A
16B
17C
Sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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