1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
Option Explicit
Sub iNiT_data()
'
Dim i As Long, n As Long, d(9) As Long
Dim i1 As Long, i2 As Long
'
n = 0
'
For i1 = 2 To 10000
'
If (Sheets("data").Cells(i1, 1).Value = "") Then Exit For
'
If (Sheets("data").Cells(i1, 2).Value = 1) Then
'
' --- clean ---
'
For i = 1 To 9
d(i) = 0
Next i
'
' --- load ---
'
For i2 = i1 To (i1 + 4)
If (Sheets("data").Cells(i1, 1).Value = Sheets("data").Cells(i2, 1).Value) Then
'
If (Sheets("data").Cells(i2, 2).Value = 1) Then d(1) = Sheets("data").Cells(i2, 4).Value: _
d(2) = Sheets("data").Cells(i2, 6).Value
If (Sheets("data").Cells(i2, 2).Value = 2) Then d(3) = Sheets("data").Cells(i2, 3).Value: _
d(4) = Sheets("data").Cells(i2, 4).Value
If (Sheets("data").Cells(i2, 2).Value = 3) Then d(5) = Sheets("data").Cells(i2, 6).Value
If (Sheets("data").Cells(i2, 2).Value = 4) Then d(6) = Sheets("data").Cells(i2, 4).Value: _
d(7) = Sheets("data").Cells(i2, 5).Value
If (Sheets("data").Cells(i2, 2).Value = 5) Then d(8) = Sheets("data").Cells(i2, 4).Value: _
d(9) = Sheets("data").Cells(i2, 7).Value
'
End If
Next i2
'
' --- save ---
'
n = n + 1
'
Sheets("result").Cells(n, 1).Value = Sheets("data").Cells(i1, 1).Value
'
For i = 1 To 9
Sheets("result").Cells(n, (i + 1)).Value = d(i)
Next i
'
End If
'
Next i1
'
MsgBox ("nb : " & n)
'
End Sub |
Partager