Hello!!
I have around 1200 names and I need to select a random list of 200 names. I tried to create a Macro using the following formula and it gives me an error message. I would appreciate any help. Or if there is an easier formula, I could use that as well.
Thank you in advance for your time.
VB![]()
Sub GetRandom()
Dim iRows As Integer
Dim iCols As Integer
Dim iBegRow As Integer
Dim iBegCol As Integer
Dim J As Integer
Dim sCells As String
Set TempDO = New DataObject
iRows = Selection.Rows.Count
iCols = Selection.Columns.Count
iBegRow = Selection.Row
iBegCol = Selection.Column
If iRows < 1201 Or iCols > 1 Then
MsgBox "Too few rows or too many columns"
Else
Randomize Timer
sCells = ""
For J = 1 To 200
iWantRow = Int(Rnd() * iRows) + iBegRow
sCells = sCells & Cells(iWantRow, iBegCol) & vbCrLf
Next J
TempDO.SetText sCells
TempDO.PutInClipboard
End If
End Sub
Bookmarks