Showing posts with label RANDBETWEEN. Show all posts
Showing posts with label RANDBETWEEN. Show all posts

Quickly fill a range of cells with a value or a formula

If you want to fill a range of cells with a value, a formula or random numbers, there is a faster way of doing it using Ctrl+Enter instead of just hitting the Enter key. To fill a range of cells with a value, follow this steps:

1. Select the range of cells that you want to fill
2. Enter the value or formula
3. Instead of hitting Enter, press Ctrl+Enter

Here’s an example on how to fill a range of cells with random numbers using this tip:

1. Select cells A1:E10
2. Enter this formula: =RANDBETWEEN(1,10)
3. Press Ctrl+Enter

This will fill the range A1:E10 with random values between 1 and 10, like this:

FILL_RANGE

Create random combinations in Excel

Imagine that you need to create random combinations of letters in Excel. In this example I want to create a 3 letters random combinations list. I want the result to be like this:

TEX
JYY
QCX
CDH
NTW

To get this kind of combinations I used the following formula:

=CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))

I’ve used the RANDBETWEEN() function to generate values between 65 and 90 because they are the ANSI codes of letters A to Z. The RANDBETWEEM() function has the following arguments:

RANDBETWEEN(bottom,top)

bottom is the smallest integer that the function will return and top is the highest.

After the generation of the random number, I use CHAR() function to return the corresponding character from the ANSI table of characters. This function has the following syntax:

CHAR(number)

number is a number between 1 and 255 that specifies which character we want to return.

On my formula, combining 3 times the formula CHAR(RANDBETWEEN(65,90) I get a combination of 3 letters.

If I wanted to get a random list of numbers between 100 and 1000, I could use the following formula:

=RANDBETWEEN(100,1000)

This will give me a list of number like the one below:

941
486
970
952
376