For example I have this list of a product and a price:
Product | Price |
---|---|
potato masher | € 27 |
dish brush | € 20 |
rolling pin | € 17 |
doormat | € 20 |
mop | € 22 |
To choose a random product, I use =INDEX($A$1:$A$5,RANDBETWEEN(1,COUNTA($A$1:$A$5)),1)
Is there a formula or way to randomly choose from two adjacent columns and put it in two other columns? So when it randomly chooses the potato masher, it chooses € 27 for the adjacent row and not for example another random price from that column (Which happens when I use the =INDEX with B instead of A).
CodePudding user response:
Assuming you don't have Microsoft365:
- Select two cells, e.g:
D1:E1
. - Use formula
=INDEX(A2:B6,RANDBETWEEN(1,5),0)
. - Confirm through: CtrlShiftEnter.
If you do have MS365, you don't need to CSE-confirm this.
CodePudding user response:
use:
=INDEX(A1:B6, RANDBETWEEN(1, COUNTA(A1:A6)))