简体   繁体   中英

Excel RANDBETWEEN as a string

How does one use a string value as a random value, I have 3 values namely SMS, Datasynergy and Other, i want to simulate live data by using the random function to assign one of the aforementioned value to my field at random?

The way i thought of it is to make a random value between 1-3 and and then go on to say if 1 = SMS else if 2 = Datasynergy else Other

But im pretty sure there must be other ways of doing this?

Thanks in advance.

试试这个

=CHOOSE(RANDBETWEEN(1,3),"SMS","Datasynergy","Other")

Another way is to use INDEX, eg

=INDEX({"SMS","Datasynergy","Other"},RANDBETWEEN(1,3))

which you can easily adapt for a longer list like this

=INDEX(List,RANDBETWEEN(1,COUNTA(List)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM