Excel problem
Moderator: Dictators in Training
- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder
Excel problem
Got a little problem going on at my job. Basically I need to write a little VB code inside an excell spread sheet, that will do a 1-a specifed number. and place the numbers in the xls sheet.
Let me see if I can explain. Our school only has a certain amount of students that are placed in the school. The placements are completely randomized for fairness.
Each possible student for each grade is given a number. For example lets say there are 400 kindergarten kids wanting to xfer from the public school to the charter school then I will need a box to pop up or to pull it from a specified cell that number I enter in. It will then randonize the numbers with no repeats and place then in a column. All 400 numbers. I can then repeat the process for the 1-12. The order is then posted at the city hall where parents can check the numbers.
Please help if you can. it has to be easy enough that I can hand off to a student since they do the lottery numbers.
Half my goats to anyone that can create this.
Let me see if I can explain. Our school only has a certain amount of students that are placed in the school. The placements are completely randomized for fairness.
Each possible student for each grade is given a number. For example lets say there are 400 kindergarten kids wanting to xfer from the public school to the charter school then I will need a box to pop up or to pull it from a specified cell that number I enter in. It will then randonize the numbers with no repeats and place then in a column. All 400 numbers. I can then repeat the process for the 1-12. The order is then posted at the city hall where parents can check the numbers.
Please help if you can. it has to be easy enough that I can hand off to a student since they do the lottery numbers.
Half my goats to anyone that can create this.

Turn calculate to Manual (Tools->Options->Calculate)
Put the names of the students in Column A. In Column B, have the integers 1-400 running down the rows. In Column c, type the function =rand() and copy it down. Hit Calculate. Now sort the Columns B and C (Not A) Ascending using Column C. Now you have a randomly ordered 400 numbers assigned to each student.
Does that work well enough for you?
Put the names of the students in Column A. In Column B, have the integers 1-400 running down the rows. In Column c, type the function =rand() and copy it down. Hit Calculate. Now sort the Columns B and C (Not A) Ascending using Column C. Now you have a randomly ordered 400 numbers assigned to each student.
Does that work well enough for you?
- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder
not really
I cant know the names, the names are only known by the parents when they apply for an app. It also has to be nice enough because last year they had reporters here. this is a fairly big event In ralieghj/wake forest area. Example 600 aplications last year, only 20 slots in Kindergarten. 1200 for highschoool range only about 15 slots available total.
It has to be easy enough that whatever kid 7-12th gets selected he/she/it can hit a button, type in the number we give him and poof it pukes out so we can print the numeric list.
It has to be easy enough that whatever kid 7-12th gets selected he/she/it can hit a button, type in the number we give him and poof it pukes out so we can print the numeric list.

Instead of having the student's names in Column A, put in the numbers 1-400. Then do what Zanchief suggested, with having a 2nd sheet that you can format nicely. Have a cell where the student enters the number he was assigned, and, in the cell next to it, have a vlookup function that will look and see what randomly assigned number was assigned to it (i.e. vlookup(CELL, Sheet1!A1:B401, 2, false). You might want to have some error checking in it too =if(iserror(vlookup(...)),"Please Re-enter Your Number",vlookup(...))
Does that work for you?
Does that work for you?
- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder
It has to be the way my administrator requested it... enter in a number in say cell 2b. it then lists a line of numbers in column a 1-whaterver number randomnly in cloum a. The problem is they had this last year however my predesscessor decided that backups were uncool and it was lost with the server1 it was on took a dive into the tank. All i need is the code to enter into a command button.

- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder
- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder
Give this a shot
Sub MenlaanRules()
Dim Total, i, j As Integer
Dim NumArray() As Double
Dim Num1, Num2, Ran1, Ran2 As Double
Total = InputBox("N00b, enter number here")
ReDim NumArray(Total - 1, 1)
For i = 0 To Total - 1
NumArray(i, 0) = i + 1
NumArray(i, 1) = Rnd()
Next i
For i = 0 To Total - 1
For j = i To Total - 1
If NumArray(j, 1) < NumArray(i, 1) Then
Num1 = NumArray(i, 0)
Num2 = NumArray(j, 0)
NumArray(i, 0) = Num2
NumArray(j, 0) = Num1
Ran1 = NumArray(i, 1)
Ran2 = NumArray(j, 1)
NumArray(i, 1) = Ran2
NumArray(j, 1) = Ran1
End If
Next j
Next i
For i = 0 To Total - 1
Range("A" & i + 1) = NumArray(i, 0)
Next i
End Sub
Sub MenlaanRules()
Dim Total, i, j As Integer
Dim NumArray() As Double
Dim Num1, Num2, Ran1, Ran2 As Double
Total = InputBox("N00b, enter number here")
ReDim NumArray(Total - 1, 1)
For i = 0 To Total - 1
NumArray(i, 0) = i + 1
NumArray(i, 1) = Rnd()
Next i
For i = 0 To Total - 1
For j = i To Total - 1
If NumArray(j, 1) < NumArray(i, 1) Then
Num1 = NumArray(i, 0)
Num2 = NumArray(j, 0)
NumArray(i, 0) = Num2
NumArray(j, 0) = Num1
Ran1 = NumArray(i, 1)
Ran2 = NumArray(j, 1)
NumArray(i, 1) = Ran2
NumArray(j, 1) = Ran1
End If
Next j
Next i
For i = 0 To Total - 1
Range("A" & i + 1) = NumArray(i, 0)
Next i
End Sub
- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder
Apparently, my public school education doesn't interface with your public school education, cuz that made zero sense.
Inside each person lives two wolves. One is loyal, kind, respectful, humble and open to the mystery of life. The other is greedy, jealous, hateful, afraid and blind to the wonders of life. They are in battle for your spirit. The one who wins is the one you feed.
kaharthemad wrote:it just has to be a generator like they had, otherwise I get to hear a bunch of whining from staff and student alike. This is what is creating the problem, plain and simple.
let'em whine. they didnt back up the old system so you have no clue how they did it. i mean wtf care if to the eye everything looks the same
For you


- kaharthemad
- NT Traveller

- Posts: 3768
- Joined: Sat Mar 27, 2004 8:47 am
- Location: Somewhere South of Disorder




