Hi there,
By simple example, you could pick whatever cells you want the scores to be in and use something like:
Rich (BB code):
Sub exa()
Dim Cell As Range
If TypeName(ActiveSheet) = "Worksheet" Then
For Each Cell In Selection
Cell.Value = Rnd_RetLong(45, 90)
Next
End If
End Sub
Function Rnd_RetLong(LowestNum As Long, HighestNum As Long) As Long
Randomize
Rnd_RetLong = Int((HighestNum - LowestNum + 1) * Rnd + LowestNum)
End Function
I don't know what your sheet is layed out like of course, but for instance to fill in random scores for random courses:
Sheet1
<TABLE style="BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 2pt; PADDING-RIGHT: 2pt; FONT-FAMILY: Arial,Arial; FONT-SIZE: 10pt" border=1 cellSpacing=0 cellPadding=0><COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 110px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"><COL style="WIDTH: 65px"></COLGROUP><TBODY><TR style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt; FONT-WEIGHT: bold"><TD> </TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD><TD>G</TD><TD>H</TD><TD>I</TD><TD>J</TD><TD>K</TD></TR><TR style="HEIGHT: 18px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">1</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BORDER-LEFT: #000000 2px solid; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">Course Number</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">1</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">2</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">3</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">4</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">5</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">6</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">7</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">8</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">9</TD><TD style="BORDER-BOTTOM: #000000 3px solid; TEXT-ALIGN: center; BACKGROUND-COLOR: #99ccff; BORDER-TOP: #000000 2px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 2px solid">10</TD></TR><TR style="HEIGHT: 18px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">2</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: center; BORDER-LEFT: #000000 2px solid; BACKGROUND-COLOR: #ffcc00; FONT-WEIGHT: bold; BORDER-RIGHT: #000000 1px solid">Name</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffcc00; BORDER-RIGHT: #000000 2px solid"> </TD></TR><TR style="HEIGHT: 17px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">3</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-LEFT: #000000 2px solid; BACKGROUND-COLOR: #ffcc00; BORDER-RIGHT: #000000 1px solid">Biff</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">65</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">84</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">80</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">86</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">62</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 2px solid"> </TD></TR><TR style="HEIGHT: 17px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">4</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-LEFT: #000000 2px solid; BACKGROUND-COLOR: #ffcc00; BORDER-RIGHT: #000000 1px solid">Tom</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">67</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">72</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">70</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">51</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">61</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 2px solid"> </TD></TR><TR style="HEIGHT: 17px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">5</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-LEFT: #000000 2px solid; BACKGROUND-COLOR: #ffcc00; BORDER-RIGHT: #000000 1px solid">Mary</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">66</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">88</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">47</TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">51</TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 1px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 2px solid">82</TD></TR><TR style="HEIGHT: 18px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">6</TD><TD style="BORDER-BOTTOM: #000000 2px solid; TEXT-ALIGN: right; BORDER-LEFT: #000000 2px solid; BACKGROUND-COLOR: #ffcc00; BORDER-RIGHT: #000000 1px solid">Sally</TD><TD style="BORDER-BOTTOM: #000000 2px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 2px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">81</TD><TD style="BORDER-BOTTOM: #000000 2px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 2px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 2px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">77</TD><TD style="BORDER-BOTTOM: #000000 2px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">82</TD><TD style="BORDER-BOTTOM: #000000 2px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 1px solid">88</TD><TD style="BORDER-BOTTOM: #000000 2px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 2px solid; BORDER-RIGHT: #000000 1px solid"> </TD><TD style="BORDER-BOTTOM: #000000 2px solid; TEXT-ALIGN: right; BORDER-RIGHT: #000000 2px solid">54</TD></TR></TBODY></TABLE>
Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
You could use (with the above listed function):
Rich (BB code):
Sub exa2()
Dim rng As Range
Dim rRow As Range
Dim lRetVal As Long
Dim i As Long
Dim aryTmp As Variant
Dim DIC As Object '<--- Dictionary
Set DIC = CreateObject("Scripting.Dictionary")
Set rng = Range("B3:K6")
rng.ClearContents
For Each rRow In rng.Rows
DIC.RemoveAll
Do While DIC.Count < 5
lRetVal = Rnd_RetLong(1, 10)
If Not DIC.Exists(lRetVal) Then DIC.Item(lRetVal) = Empty
Loop
aryTmp = DIC.Keys
For i = LBound(aryTmp) To UBound(aryTmp)
rRow.Cells(aryTmp(i)).Value = Rnd_RetLong(45, 90)
Next
Next
DIC.RemoveAll
End Sub
To post sample data:
Excel Jeanie
Or
Richard Schollar's HTML Maker
Hope that helps,
Mark