- 帖子
- 522
- 主題
- 36
- 精華
- 1
- 積分
- 603
- 點名
- 0
- 作業系統
- win xp sp3
- 軟體版本
- Office 2003
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2012-12-13
- 最後登錄
- 2021-7-11
|
2#
發表於 2014-6-27 14:55
| 只看該作者
回復 1# scjiao
試試看:- Sub test()
- Dim sh1, sh2 As Worksheet
- Dim i, j, k As Integer
- Set sh1 = Sheets("MPS_TEST")
- Set sh2 = Sheets("排程")
- Sheets("排程").Activate
- With sh2
- For i = 1 To 35
- sh1.Cells(i * 8 - 3, 1).Resize(8, 1) = .Cells(i * 2 + 3, 1)
- For j = 10 To 50
- .Cells(i * 2 + 3, j).Select
- If .Cells(i * 2 + 3, j) <> "" Then
- .Cells(3, .Cells(i * 2 + 3, j).Column).Select
- sh1.Cells(i * 8 - 3, 2).Resize(8, 1) = .Cells(3, .Cells(i * 2 + 3, j).Column)
- sh1.Cells(i * 8 - 3, 3).Resize(8, 1) = .Cells(3, .Cells(i * 2 + 3, j).Column)
- k = j
- Do
- k = k + 1
- If .Cells(i * 2 + 3, k) <> "" Then
- sh1.Cells(i * 8 - 3, 3).Resize(8, 1) = .Cells(3, .Cells(i * 2 + 3, k).Column)
- End If
- Loop Until k > 50
- If k > 50 Then GoTo nextI
- End If
- Next
- nextI:
- Next
- End With
- End Sub
複製代碼 |
|