Top 6 # Random Số Trong Excel Xem Nhiều Nhất, Mới Nhất 3/2023 # Top Trend | Trucbachconcert.com

Hướng Dẫn Cách Tạo Random Số Trong Excel Bằng Hàm Random

Tuyệt đỉnh Excel – Trở thành bậc thầy Excel trong 16 giờ

Tầm quan trọng của dữ liệu ngẫu nhiên từ random số

Hiện nay nhu cầu hỏi đáp về kiến thức Excel, các tình huống trong Excel là rất nhiều. Nhưng nếu không có dữ liệu mẫu, không có tình huống cụ thể thì không thể hình dung được vấn đề mà bạn gặp phải là gì. Khi được yêu cầu dữ liệu mẫu, thường Gitiho nhận được câu trả lời: “không thể đưa lên được vì tính bảo mật thông tin”.

Vậy tại sao bạn không tạo 1 bảng dữ liệu ngẫu nhiên theo cách random số để làm mẫu? Như vậy không ảnh hưởng gì tới bảo mật thông tin mà vẫn thể hiện được đúng bản chất của vấn đề bạn đang gặp phải.

Khi bạn cần lấy ví dụ trong bằng Excel, hoặc khi bạn muốn tạo các bài kiểm tra trong Excel, điều bạn quan tâm là cách viết hàm, loại dữ liệu chứ không phải giá trị trong từng ô dữ liệu. Và nếu phải nhập tay từng ô thì rất mất công. Hãy để Excel làm việc đó 1 cách ngẫu nhiên mà vẫn trong phạm vi kiểm soát của chúng ta hàm Random .

Cách sử dụng hàm RAND trong Excel để random số

Hàm RAND được hiểu là RANDOM, có nghĩa là ngẫu nhiên. Tác dụng của hàm RAND là tạo ra một số ngẫu nhiên trong phạm vi từ số 0 tới số 1, tức là một số có phần thập phân nhưng lớn hơn 0 và nhỏ hơn 1.

Cú pháp của hàm RAND: =RAND()

Hàm RAND có đặc điểm:

Kết quả của hàm sẽ luôn tự động thay đổi mỗi khi file Excel nhận được yêu cầu tính toán. Khi file Excel của bạn thiết lập chế độ tính toán là Automatic thì chỉ cần bạn nhập dữ liệu vào 1 ô khác là kết quả hàm RAND sẽ tự thay đổi mà không hề tác động vào ô chứa hàm RAND.

Giá trị của hàm nằm trong khoảng lớn hơn 0 và nhỏ hơn 1.

Số ngẫu nhiên luôn là số lẻ (kết thúc với số cuối cùng là số lẻ).

Một số ứng dụng của hàm RAND:

Muốn lấy random số lớn hơn hoặc bằng 0 và nhỏ hơn n, dùng công thức: =RAND() * n

Muốn lấy random số trong bảng chữ cái tiếng Anh. Biết bảng chữ cái tiếng Anh có 26 chữ cái nên đầu tiên các bạn cần lấy một số nguyên ngẫu nhiên giữa 1 và 26 với công thức: =INT(RAND() * 26 + 1)

Muốn trả về một chữ cái nằm trong bảng chữ cái Alphabet. Được biết, theo bảng mã ANSI, những ký tự viết hoa (A tới Z) nằm từ mã ANSI 65 đến mã ANSI 90. Dùng hàm CHAR với công thức: =CHAR(INT(RAND() * 26 + 1) + 64)

Cách sử dụng hàm RANDBETWEEN trong Excel để random số

Hàm RANDBETWEEN được hiểu là Random + Between, nghĩa là tạo random số trong 1 khoảng (từ số… đến số…). Tác dụng của hàm Random này là tạo ra một số ngẫu nhiên trong một phạm vi được chỉ định sẵn trong Excel, có thể là số âm hoặc số dương, nhưng luôn luôn là số nguyên.

Cú pháp của hàm RANDBETWEEN: =RANDBETWEEN(Từ số, Đến số)

Các bạn có thể xem một số ví dụ sau đây:

Đặc điểm của hàm RANDBETWEEN:

Số bắt đầu phải nhỏ hơn số kết thúc, không giới hạn số âm hay số dương, số có phần thập phân hay không.

Kết quả luôn là 1 số nguyên (không có phần thập phân) nhưng có thể là số âm.

Có thể dùng hàm RANDBETWEEN để random số với dữ liệu là dạng Số hoặc dạng Ngày, Giờ. Với dữ liệu thời gian thì không được dùng số âm.

Nguyên tắc tính của hàm RANDBETWEEN:

Giá trị tạo ra bởi RandBetween = (Số cuối – Số đầu) * Số ngẫu nhiên + Số đầu

Ví dụ về ứng dụng của hàm RANDBETWEEN:

Cho bảng dữ liệu A1:C10 trong trang tính Excel, trong đó dữ liệu ở các cột A, B, C sẽ phát sinh một cách ngẫu nhiên từ dòng 2 tới dòng 9 dựa theo nội dung có sẵn trong bảng E2:G7

Trong trường hợp này chúng ta dùng hàm VLOOKUP kết hợp với hàm RANDBETWEEN làm hàm Random như sau:

Họ tên: Sẽ lấy ngẫu nhiên từ 1 đến 6, sau đó dựa trên kết quả random số thu được bạn sẽ tham chiếu bằng hàm VLOOKUP để lấy tên tương ứng theo số thứ tự đó:

=VLOOKUP(RANDBETWEEN(1,6), $E$1:$G$7, 2, 0)

Bộ phận: vì chỉ có 3 bộ phận nên lấy random số từ 1 đến 3, sau đó kết hợp trong hàm VLOOKUP để lấy tên bộ phận tương ứng với số thứ tự thu được:

=VLOOKUP(RANDBETWEEN(1,3), $E$1:$G$7, 3, 0)

Khi đó kết quả thu được là:

Số ngày công: vì không cụ thể giới hạn số ngày công nên bạn có thể lấy ngẫu nhiên theo 1 phạm vi tự chọn, ví dụ từ 10 đến 30 = RANDBETWEEN(10,30)

Tài liệu kèm theo bài viết

Với sứ mệnh: ” Mang cơ hội phát triển kỹ năng, phát triển nghề nghiệp tới hàng triệu người “, đội ngũ phát triển đã và đang làm việc với những học viện, trung tâm đào tạo, các chuyên gia đầu ngành để nghiên cứu và xây dựng lên các chương trình đào tạo từ cơ bản đến chuyên sâu xung quanh các lĩnh vực: Tin học văn phòng, Phân tích dữ liệu, Thiết kế, Công nghệ thông tin, Kinh doanh, Marketing, Quản lý dự án…

50+ khách hàng doanh nghiệp lớn trong nhiều lĩnh vực như: Vietinbank, Vietcombank, BIDV, VP Bank, TH True Milk, VNPT, FPT Software, Samsung SDIV, Ajinomoto Việt Nam, Messer,…

Gitiho tự hào khi được đồng hành cùng:

How To Randomize A List In Excel: Sort Randomly Cells, Rows And Columns

The tutorial will teach you two quick ways to randomize in Excel: perform random sort with formulas and shuffle data by using a special tool.

Microsoft Excel provides a handful of different sorting options including ascending or descending order, by color or icon, as well as custom sort. However, it lacks one important feature – random sort. This functionality would come in handy in situations when you need to randomize data, say, for an unbiased assigning of tasks, allocation of shifts, or picking a lottery winner. This tutorial will teach you a couple of easy ways to do random sort in Excel.

How to randomize a list in Excel with a formula

Although there is no native function to perform random sort in Excel, there is a function to generate random numbers (Excel RAND function) and we are going to use it.

Assuming you have a list of names in column A, please follow these steps to randomize your list:

Insert a new column next to the list of names you want to randomize. If your dataset consists of a single column, skip this step.

In the first cell of the inserted column, enter the RAND formula: =RAND()

Either way, Excel automatically expands the selection and sorts the names in column A as well:

Tips & notes:

Excel RAND is a volatile function, meaning that new random numbers are generated every time the worksheet is recalculated. So, if you are not happy with how your list has been randomized, keep hitting the sort button until you get the desired result.

To prevent the random numbers from recalculating with every change you make to the worksheet, copy the random numbers, and then paste them as values by using the Paste Special feature. Or, simply delete the column with the RAND formula if you don’t need it any longer.

The same approach can be used to randomize multiple columns. To have it done, place two or more columns side by side so that the columns are contiguous, and then perform the above steps.

How to shuffle data in Excel with Ultimate Suite

If you don’t have time to fiddle with formulas, use the Shuffle Cells tool included in our Ultimate Suite for Excel to do a random sort faster.

The Shuffle pane will appear on the left side of your workbook. You select the range where you want to shuffle data, and then choose one of the following options:

Cells in each row – shuffle cells in each row individually.

Cells in each column – randomly sort cells in each column.

Entire rows – shuffle rows in the selected range.

Entire columns – randomize the order of columns in the range.

All cells in the range – randomize all cells in the selected range.

In this example, we need to shuffle cells in column A, so we go with the third option:

And voilà, our list of names is randomized in no time:

If you are curious to try this and explore a lot more fascinating features included with Ultimate Suite for Excel, you are welcome to download a 14-day trial version.

You may also be interested in

Hàm Random Trong Excel (Hàm Rand), Cách Sử Dụng Hàm Random Và Ví Dụ

Mô tả hàm Random

Hàm RAND() trả về một số thực ngẫu nhiên. Đó có thể là một số thực lớn hơn 0 hoặc nhỏ hơn một số bất kì, thậm chí nó còn là một chữ cái thuộc bảng chữ cái Alphabet.

Cú pháp hàm Random

RAND()

– Hàm Rand() là hàm không chứa tham số giá trị trả về sẽ là các số ngẫu nhiên nằm trong khoảng từ 0 tới 1.

– Muốn lấy giá trị ngẫu nhiên nằm trong khoảng bất kì, ví dụ các giá trị lớn hơn bằng 0 và nhỏ hơn n thực hiện câu lệnh sau: =RAND() * n

– Bạn muốn lấy các giá trị ngẫu nhiên lớn hơn hoặc bằng n và nhỏ hơn m thực hiện câu lệnh: : =RAND() * (m-n) + n

Chú ý khi sử dụng hàm Random

– Hàm RAND() là hàm trả về giá trị ngẫu nhiên và giá trị này sẽ thay đổi mỗi khi bạn cập nhật hay mở lại bảng tính.

– Trong trường hợp bạn muốn lưu giá trị đầu tiên của hàm RAND(), không muốn thay đổi giá trị đó bạn chỉ cần nhấn F5 sau đó nhấn Enter giá trị đầu tiên hàm RAND()) sinh ra được lưu lại cố định.

Ví dụ hàm Random

Ví dụ 1: Sử dụng hàm RAND() thực hiện các yêu cầu sau:

– Lấy một số ngẫu nhiên trong khoảng từ 0 tới 1.

– Lấy một số ngẫu nhiên nằm trong khoảng từ 0 tới 90

– Lấy một số ngẫu nhiên nằm trong khoảng từ 88 tới 188

Cách làm:

– Lấy một số ngẫu nhiên sử dụng cú pháp = RAND()

– Lấy một số ngẫu nhiên nằm trong khoảng từ 0 tới 90: = RAND()*90

– Lấy một số ngẫu nhiên nằm trong khoảng từ 88 tới 188: = RAND()*(188-88)+88

Để lấy một số ngẫu nhiên bằng cách sử dụng hàm RAND() thực hiện như sau:

– Thứ nhất sử dụng công thức lấy số ngẫu nhiên trong một khoảng và sử dụng hàm Int() để lấy phần nguyên của số ngẫu nhiên đó.

– Thứ hai để cố định số chữ số của số ngẫu nhiên cần lấy ta đặt n = 10(x-1) và m = 10x với x chính là số chữ số của số ngẫu nhiên cần lấy. Ví dụ lấy một số ngẫu nhiên có 4 chữ số dùng công thức: = INT(RAND()*(10000-1000)+1000)

Như vậy áp dụng công thức trên ta có bảng dữ liệu cần lấy số ngẫu nhiên có x chữ số:

How To Generate Random Numbers In Excel (A Step

There may be cases when you need to generate random numbers in Excel.

For example, to select random winners from a list or to get a random list of numbers for data analysis or to create random groups of students in class.

In this tutorial, you will learn how to generate random numbers in Excel (with and without repetitions).

Generate Random Numbers in Excel

There are two worksheet functions that are meant to generate random numbers in Excel: RAND and RANDBETWEEN.

RANDBETWEEN function would give you the random numbers, but there is a high possibility of repeats in the result.

RAND function is more likely to give you a result without repetitions. However, it only gives random numbers between 0 and 1. It can be used with RANK to generate unique random numbers in Excel (as shown later in this tutorial).

Generate Random Numbers using RANDBETWEEN function in Excel

Excel RANDBETWEEN function generates a set of integer random numbers between the two specified numbers.

RANDBETWEEN function takes two arguments – the Bottom value and the top value. It will give you an integer number between the two specified numbers only.

For example, suppose I want to generate 10 random numbers between 1 and 100.

Here are the steps to generate random numbers using RANDBETWEEN:

Select the cell in which you want to get the random numbers.

In the active cell, enter =RANDBETWEEN(1,100).

Hold the Control key and Press Enter.

This will instantly give me 10 random numbers in the selected cells.

While RANDBETWEEN makes it easy to get integers between the specified numbers, there is a high chance of repetition in the result.

For example, when I use the RANDBETWEEN function to get 10 random numbers and use the formula =RANDBETWEEN(1,10), it gives me a couple of duplicates.

If you’re OK with duplicates, RANDBETWEEN is the easiest way to generate random numbers in Excel.

Note that RANDBETWEEN is a volatile function and recalculates every time there is a change in the worksheet. To avoid getting the random numbers recalculate, again and again, convert the result of the formula to values.

Generate Unique Random Numbers using RAND and RANK function in Excel

I tested the RAND function multiple times and didn’t find duplicate values. But as a caution, I recommend you check for duplicate values when you use this function.

Suppose I want to generate 10 random numbers in Excel (without repeats).

Here are the steps to generate random numbers in Excel without repetition:

Select the cells in which you want to get the random numbers.

In the active cell, enter =RAND()

Hold the Control key and Press Enter.

Select all the cell (where you have the result of the RAND function) and convert it to values.

In the adjacent column, use the following formula: =RANK.EQ(A2,$A$2:$A$11)

Now you can use the values in column B as the random numbers.

Note: RAND is a volatile formula and would recalculate every time there is any change in the worksheet. Make sure you have converted all the RAND function results to values.

Caution: While I checked and didn’t find repetitions in the result of the RAND function, I still recommend you check once you have generated these numbers. You can use Conditional Formatting to highlight duplicates or use the Remove Duplicate option to get rid of it.

You May Also Like the Following Excel Tutorials: