返回列表 上一主題 發帖

[發問] 如何取得sheet1每一欄的資料每隔5筆複製到sheet2

如題
例如上圖為sheet1的資料
我想要複製上面兩列到sheet2
然後在將下面的值每五格取一個直到shee ...
yaya1986 發表於 2016-5-2 14:47
  1. Sub nn()
  2.   Dim lSRow&, lTRow&
  3.   Dim rTar As Range
  4.   Dim wsTar As Worksheet
  5.   
  6.   Set wsTar = Sheets("Sheet2")
  7.   
  8.   With Sheets("Sheet1")
  9.     wsTar.Cells.Clear
  10.     .[A1:D2].Copy wsTar.[A1]
  11.     lTRow = 7
  12.     lSRow = 3
  13.     Set rTar = .Cells(lTRow, 1)
  14.     While rTar + rTar.Offset(, 1) + rTar.Offset(, 2) + rTar.Offset(, 3) <> 0
  15.       rTar.Resize(, 4).Copy wsTar.Cells(lSRow, 1)
  16.       lSRow = lSRow + 1
  17.       lTRow = lTRow + 5
  18.       Set rTar = .Cells(lTRow, 1)
  19.     Wend
  20.   End With
  21. End Sub
複製代碼
每隔5筆複製-a.zip (7.59 KB)

TOP

        靜思自在 : 我們最大的敵人不是別人.可能是自己。
返回列表 上一主題