- 帖子
- 561
- 主題
- 160
- 精華
- 0
- 積分
- 725
- 點名
- 0
- 作業系統
- WINDOWS
- 軟體版本
- xp
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 桃園
- 註冊時間
- 2014-9-10
- 最後登錄
- 2024-8-7
  
|
2#
發表於 2016-9-7 10:48
| 只看該作者
如下試試
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 |
|