S
sulie
hi,
i have 2644 data students in excel, i want to run a macro to randomize
their names, and then put them into new worksheet, with all their
details, such as their age, birthday, address and etc, which are
located in different columns, but same rows as the names. here the
macro function that i use to randomize the name into new worksheet, but
it only return the students names. how to include other columns too?
Sub ExtractRandom20()
Dim tmp As Collection
Dim rngSrc As Range
Dim rngTgt As Range
Dim r&
Set rngSrc = Worksheets(2).Range("a2:a2645")
Set rngTgt = Worksheets(1).Range("a1:a2644")
Randomize
Set tmp = New Collection
On Error Resume Next
With rngSrc
While tmp.Count < rngTgt.Rows.Count
r = Int(Rnd * .Rows.Count + 1)
tmp.Add .Cells(r, 1).Value, CStr(r)
Wend
End With
For r = 1 To tmp.Count
rngTgt(r, 1) = tmp(r)
Next
End Sub
n any idea how to grouping the students into 100 groups?(which
estimately 28 persons per group)
thanks for any idea..
i have 2644 data students in excel, i want to run a macro to randomize
their names, and then put them into new worksheet, with all their
details, such as their age, birthday, address and etc, which are
located in different columns, but same rows as the names. here the
macro function that i use to randomize the name into new worksheet, but
it only return the students names. how to include other columns too?
Sub ExtractRandom20()
Dim tmp As Collection
Dim rngSrc As Range
Dim rngTgt As Range
Dim r&
Set rngSrc = Worksheets(2).Range("a2:a2645")
Set rngTgt = Worksheets(1).Range("a1:a2644")
Randomize
Set tmp = New Collection
On Error Resume Next
With rngSrc
While tmp.Count < rngTgt.Rows.Count
r = Int(Rnd * .Rows.Count + 1)
tmp.Add .Cells(r, 1).Value, CStr(r)
Wend
End With
For r = 1 To tmp.Count
rngTgt(r, 1) = tmp(r)
Next
End Sub
n any idea how to grouping the students into 100 groups?(which
estimately 28 persons per group)
thanks for any idea..