Sub 轉置()
Sheet1.[J3:N65536].ClearContents
X = Sheet1.[B65536].End(xlUp).Row
Y1 = Sheet1.[J65536].End(xlUp).Row
Y2 = Sheet1.[K65536].End(xlUp).Row
Y3 = Sheet1.[L65536].End(xlUp).Row
Y4 = Sheet1.[M65536].End(xlUp).Row
Y5 = Sheet1.[N65536].End(xlUp).Row
For M = 3 To X
If Sheet1.Cells(M, 3) = "一" Then
Sheet1.Cells(Y1 + 1, 10) = Sheet1.Cells(M, 2)
Y1 = Y1 + 1
End If
If Sheet1.Cells(M, 3) = "二" Then
Sheet1.Cells(Y2 + 1, 11) = Sheet1.Cells(M, 2)
Y2 = Y2 + 1
End If
If Sheet1.Cells(M, 3) = "三" Then
Sheet1.Cells(Y3 + 1, 12) = Sheet1.Cells(M, 2)
Y3 = Y3 + 1
End If
If Sheet1.Cells(M, 3) = "四" Then
Sheet1.Cells(Y4 + 1, 13) = Sheet1.Cells(M, 2)
Y4 = Y4 + 1
End If
If Sheet1.Cells(M, 3) = "五" Then
Sheet1.Cells(Y5 + 1, 14) = Sheet1.Cells(M, 2)
Y5 = Y5 + 1
End If
Next
End Sub作者: ikboy 時間: 2016-9-7 11:49
Sub TEST()
Dim xR As Range, xF As Range
For Each xR In Range([B3], [B65536].End(xlUp))
Set xF = [J2:N2].Find(xR(1, 2), Lookat:=xlPart)
If Not xF Is Nothing Then xF(60000, 1).End(xlUp)(2, 1) = xR
Next
End Sub作者: chiang0320 時間: 2016-9-21 23:30