Random number & Vlookup

BladeFisher

New Member
Joined
Jun 5, 2011
Messages
13
I am wanting to generate a random number then in the same function take the resultant number compare to a list and it is the result of the list that is entered into the cell.

E.g. Rand ()*100 say answer is 37 and in the lookup 37 equates to Oxford. Lookup table = 2 column, 100 entries, different answers for each value which is a text string.

Sounds simple but getting tied up in knots
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Assuming your lookup table is in A1:B100 and your random number is in C1, then I think this formula does what you want...

=VLOOKUP(C1,A2:B100,2)
 
Upvote 0
I am wanting to generate a random number then in the same function take the resultant number compare to a list and it is the result of the list that is entered into the cell.

E.g. Rand ()*100 say answer is 37 and in the lookup 37 equates to Oxford. Lookup table = 2 column, 100 entries, different answers for each value which is a text string.

Sounds simple but getting tied up in knots
For that to happen RAND() would have to return EXACTLY 0.37.

The chances of that happening are extemely slim.

Maybe the problem you're having is that your lookup table consists of whole numbers and RAND()*100 is returning values like 37.01230254821024588.

If you want a random number from 1 to 100 then use the RANDBETWEEN() function:

=VLOOKUP(RANDBETWEEN(1,100),...

Note that the RANDBETWEEN function requires the Analysis ToolPak add-in be installed if you're using a version of Excel prior to Excel 2007. If you
enter the formula and get a #NAME? error look in Excel help for the RANDBETWEEN function. It'll tell you how to fix the problem.

Or, if you're using Excel 2003 or earlier and you don't/can't have the ATP installed...

INT(RAND()*100+1)

=VLOOKUP(INT(RAND()*100+1),...
 
Upvote 0
For that to happen RAND() would have to return EXACTLY 0.37.
I think anything between [0.37 ... 0.38)
 
Upvote 0
It wouldn't, but it need not be for a range lookup, which is what the OP's formula is, Tony.
 
Upvote 0
It wouldn't, but it need not be for a range lookup, which is what the OP's formula is, Tony.
We don't know what the OPs formula looks like. They haven't posted one.

All we know is that the OP says RAND()*100 might return 37 which is very unlikely.

We need further clarification from the OP.
 
Last edited:
Upvote 0
For that to happen RAND() would have to return EXACTLY 0.37.

The chances of that happening are extemely slim.

Maybe the problem you're having is that your lookup table consists of whole numbers and RAND()*100 is returning values like 37.01230254821024588.

If you want a random number from 1 to 100 then use the RANDBETWEEN() function:

=VLOOKUP(RANDBETWEEN(1,100),...

Note that the RANDBETWEEN function requires the Analysis ToolPak add-in be installed if you're using a version of Excel prior to Excel 2007. If you
enter the formula and get a #NAME? error look in Excel help for the RANDBETWEEN function. It'll tell you how to fix the problem.

Or, if you're using Excel 2003 or earlier and you don't/can't have the ATP installed...

INT(RAND()*100+1)

=VLOOKUP(INT(RAND()*100+1),...
Thanks for that. Yes sorted the query. Am using an old version of Excel.

Regards

Richard
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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