China Naming Network - Weather knowledge - Random decision lottery

Random decision lottery

You can do this by using a custom function.

Give examples. For example, there is a data table as shown in the following figure:

As shown in the figure, there are 30 broken sentences in column A, and C 1 needs 5 randomly selected sentence combinations.

Step 1: Click the development tool-Visual Basic. As shown in the figure:

Step 2: Insert the module and compile the code as follows:

Common temperature in integer form (1 to 5)

Function sjf ()

sjf = " "

Call RndNumberNoRepeat

For i = 1 to 5

Sjf = sjf& cell (temperature (i)+1, 1). text

If I<5, then SJF = SJF&","

Next, I

End function

Public child RndNumberNoRepeat ()

Dim RndNumber, I, k and Maxrec are integers.

Randomization (timer)? Initialize the random number generator.

Maxrec = 30

k = 1

Do While k & lt= 5

Rnd number = Int(Maxrec * Rnd)+ 1

Temperature (k)= rnd number

For i = 1 to k

If temp(i) = RndNumber, exit.

Next, I

If i = k, then k = i+1

?

ring

End joint

Step 3: Enter the formula in C 1: =sjf (). The result is as shown in the figure: