HELP ME!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if anyone knows how to create samples in excel. I have a
list of 6 numbers and I want to list all possible random samples of 3. Is
there a way to do it?? PLEASE HELP ME!
 
Hi,
Assume your 6 numbers are in cells A1:F1. The following macro,
starting from row 10, in columns A:C, will produce all the
combinations of 3:

Sub combos()
rnum = 10
For i = 1 To 6
For j = i + 1 To 6
For k = j + 1 To 6
If i <> j And i <> k And j <> k Then
Cells(rnum, 1) = Cells(1, i)
Cells(rnum, 2) = Cells(1, j)
Cells(rnum, 3) = Cells(1, k)
rnum = rnum + 1
End If
Next k
Next j
Next i
End Sub

Write back if you need adjustments based on your original numbers'
locations.

HTH
Kostis Vezerides
 
vezerid said:
Hi,
Assume your 6 numbers are in cells A1:F1. The following macro,
starting from row 10, in columns A:C, will produce all the
combinations of 3:

Sub combos()
rnum = 10
For i = 1 To 6
For j = i + 1 To 6
For k = j + 1 To 6
If i <> j And i <> k And j <> k Then
Cells(rnum, 1) = Cells(1, i)
Cells(rnum, 2) = Cells(1, j)
Cells(rnum, 3) = Cells(1, k)
rnum = rnum + 1
End If
Next k
Next j
Next i
End Sub

Write back if you need adjustments based on your original numbers'
locations.

HTH
Kostis Vezerides
I'm sorry I really don't understand this, is there any other easier way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top