Sheet1
­
1
Public
Function
pickRandomPotw()
As
Integer
Dim
holder
As
Integer
holder
=
Int((
764
­
1
+
1)
*
Rnd
+
2)
pickRandomPotw
=
holder
End
Function
Private
Sub
CommandButton1_
Click()
Dim
rndNum
As
Integer,
i
As
Integer,
j
As
Integer
Dim
numTimes
As
Integer,
track
As
Integer,
h
As
Integer
Dim
adjid
As
String
'
There
are
547
facilities,
2
to
548
'
There
are
764
potws,
2
to
765
j
=
2
'
counter
for
random
assigns
rows
'
Loop
through
the
facilities
For
i
=
2
To
548
'
Only
Indirects
If
Sheet2.
Cells(
i,
5)
=
"
I"
Then
'
Check
for
only
facilities
with
a
weight
>
1
If
Sheet2.
Cells(
i,
7)
>
1
Then
numTimes
=
Sheet2.
Cells(
i,
7)
track
=
1
For
h
=
1
To
numTimes
­
1
If
track
<
10
Then
adjid
=
Sheet2.
Cells(
i,
1)
&
".
0"
&
track
Else
adjid
=
Sheet2.
Cells(
i,
1)
&
"."
&
track
End
If
Sheet1.
Cells(
j,
1)
=
Sheet2.
Cells(
i,
1)
Sheet1.
Cells(
j,
2)
=
adjid
Sheet1.
Cells(
j,
3)
=
Sheet3.
Cells(
pickRandomPotw(),
1)
track
=
track
+
1
j
=
j
+
1
Next
h
End
If
'
check
weight
End
If
'
indirects
Next
i
End
Sub
