- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 15
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-1-17
|
3#
發表於 2011-12-20 19:15
| 只看該作者
回復 1# tonycho33 - Sub 轉置()
- Dim A As Range, Ar(), Ay(), i%, j%, Ary(), s&
- With Sheets("a")
- For Each A In .Range("A2", .Cells(.Rows.Count, 1).End(xlUp)).SpecialCells(xlCellTypeConstants)
- Ar = A.Resize(, 4)
- Ay = .Range(A.Offset(, 6), A.Offset(, 6).End(xlToRight).Offset(2)).Value
- For i = 1 To UBound(Ay, 2)
- ReDim Preserve Ary(7, s)
- Ary(0, s) = Ar(1, 1): Ary(1, s) = Ar(1, 2): Ary(6, s) = Ar(1, 4)
- For j = 1 To UBound(Ay, 1)
- Ary(j + 1, s) = Ay(j, i)
- Next
- s = s + 1
- Next
- Next
- End With
- Sheets("b").UsedRange.Offset(1) = ""
- Sheets("b").[A2].Resize(s, 7) = Application.Transpose(Ary)
- End Sub
複製代碼
sheet 欄位轉換.rar (11.01 KB)
|
|