Re: Randomly Select 25 Records out of 500 and Enter a Y in empty Column
Try adding the one row I added below:
Code
Sub RandomRows()
Dim d As Object, r As Range, vKeys, x&
'get a set of 25 unique numbers
Set d = CreateObject("Scripting.Dictionary")
While d.Count < 26
'Define the min,max of your numbers
Y = "Y"
x = RndBetween(10, 510)
If Not d.Exists(x) Then d.Add x, Empty
Wend
'Create a multiarea range
vKeys = d.keys
Set r = Rows(vKeys(0))
For x = 1 To UBound(vKeys)
Set r = Union(r, Rows(vKeys(x)))
Range("A" & vKeys(x)).Value = "Y" '***** ADDED *****
Next
'Select it
End Sub
Function RndBetween(low&, high&) As Long
RndBetween = CLng(Rnd * (high - low)) + low
End Function
Display More