Sub main()
Dim iMax%, iMin%, iMid%, iColumn%, iRow%
Dim iNum%, iI%
Dim vDatabase, vOutput
Set vDatabase = Sheets("DATABASE")
Set vOutput = Sheets("OUTPUT")
iMax = 182
iColumn = iMax
iRow = 70
With vDatabase
While Left(.Cells(1, iColumn), 3) = "Max"
iColumn = iColumn + 1
Wend
iMin = iColumn
While Left(.Cells(1, iColumn), 3) = "Min"
iColumn = iColumn + 1
Wend
iMid = iColumn
End With
iColumn = 3
With vOutput
For iNum = 9 To 12
For iI = 0 To .Cells(2, iNum) - 1
.Cells(iRow, iColumn) = vDatabase.Cells(1, iMax)
iMax = iMax + 1
iColumn = iColumn + 1
Next iI
For iI = 0 To .Cells(3, iNum) - 1
.Cells(iRow, iColumn) = vDatabase.Cells(1, iMin)
iMin = iMin + 1
iColumn = iColumn + 1
Next iI
For iI = 0 To .Cells(4, iNum) - 1
.Cells(iRow, iColumn) = vDatabase.Cells(1, iMid)
iMid = iMid + 1
iColumn = iColumn + 1
Next iI
Next iNum
End With
End Sub作者: sandra_wang 時間: 2010-12-15 10:52