Sub list_outputs2()
Dim MyPriors(), MyFreqs(), CCell As Range, x As Long, RRow As Long, HasPrior As Boolean, y As Long, a As Long, b As Long
RRow = 12 ' first row to put output data in
HasPrior = False
x = 0
For Each CCell In Range("MyRange").Columns(3).Cells
If CCell > 0 Then
HasPrior = True
ReDim Preserve MyPriors(x)
MyPriors(x) = CCell.Offset(0, -2)
ReDim Preserve MyFreqs(x)
MyFreqs(x) = CCell.Offset(0, -1)
x = x + 1
End If
Next CCell
x = x - 1
y = 0
a = 1
Do While a <= WorksheetFunction.CountA(Range("A1:A10")) + 1
b = 1
If HasPrior = True Then
Do While b <= MyFreqs(y)
Cells(RRow, 1) = MyPriors(y)
RRow = RRow + 1
b = b + 1
Loop
If y = UBound(MyPriors) Then y = 0 Else y = y + 1
End If
If Range("MyRange").Cells(a, 3) > 0 Then
Do While Range("MyRange").Cells(a, 3) > 0
a = a + 1
Loop
End If
b = 1
Do While b <= Range("MyRange").Cells(a, 2)
Cells(RRow, 1) = Range("MyRange").Cells(a, 1)
RRow = RRow + 1
b = b + 1
Loop
a = a + 1
Loop
Bookmarks