How to Random Name List with two person at once in VBA of MS Excel
Please follow the each step as below:1-First you create Name list in one column and determine the two cells to show the random name
2- then create a module VBA code by press Alt+F11 .
Example The A column is theName list in one column ,and the two cells to show the random name are G2 and G3 .
Please see the following code:
Sub PickSomebody()
Dim class As Range
Set class = Range("A2", Range("A2").End(xlDown))
n = class.Rows.Count
Range("G2") = class(Int(n + 1) * Rnd + Lowerbound, 1)
Range("G3") = class(Int(n + 1) * Rnd + Lowerbound, 1)
End Sub
0 comments:
Post a Comment