Sub sorting4()
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
Dim e As Single
Dim TempNum1 As Single
Dim AdjuNum1 As Integer
TempNum1 = 1
AdjuNum1 = 0
For a = 1 To 2 Step 1
'paste name
Cells(a + 7, 1) = Cells(a, 1)
For b = 1 To 7 Step 1
If IsEmpty(Cells(a, 1 + b)) = False Then
'paste other number
c = InStr(Cells(a, 1 + b), "=")
'MsgBox ("Cells(a, 1 + b)-->" & Cells(a, 1 + b) & " c=" & c)
'item name
Cells(5, 1) = Left(Cells(a, 1 + b), c - 1) 'name temp
Cells(5, 2) = Mid(Cells(a, 1 + b), c + 1, c + 10) 'number temp
'判斷若為true,則直接填入數字,若為fales則填上name,跟數字
For e = 1 To TempNum1 Step 1
If (Cells(7, 1 + e) = Cells(5, 1)) = True Then
' MsgBox ("e=" & e & " " & "Cells(7, 1 + e)=" & Cells(7, 1 + e) & " " & "Cells(5, 1)=" & Cells(5, 1) & " ")
Cells(7 + a, 1 + e) = Cells(5, 2) 'number
AdjuNum1 = AdjuNum1 + 10000
' MsgBox ("true" & " AdjuNum1=" & AdjuNum1)
Else
AdjuNum1 = AdjuNum1 + 1
End If
Next e
If AdjuNum1 < 5000 Then
'MsgBox ("e=" & e & " " & "Cells(7, 1 + e)=" & Cells(7, 1 + e) & " " & "Cells(5, 1)=" & Cells(5, 1) & " ")
Cells(7 + a, 1 + TempNum1) = Cells(5, 2) 'number
Cells(7, 1 + TempNum1) = Cells(5, 1) 'name
TempNum1 = TempNum1 + 1
' MsgBox ("false" & " AdjuNum1=" & adjumun1)
' MsgBox ("tempNum1=" & TempNum1)
AdjuNum1 = 0
Else
AdjuNum1 = 0
End If
'msgbox(true)
End If
' MsgBox (TempNum1)
Next b
Next a
End Sub



