複数行を指定した場合
たとえば、53行目、1050目、2050目
No1の複数の行番号指定
Sub Test3()
Dim buf As Variant, SRow() As Variant
Dim i As Long, k As Long, j As Long: j = 0
SRow = Array(53, 1050, 2050)
With Sheets("Sheet8")
.Cells(4, "O").Resize(6003, 50).ClearContents
For k = 4 To 6003 Step UBound(SRow) - LBound(SRow) + 1
For i = LBound(SRow) To UBound(SRow)
buf = .Range(.Cells(SRow(i) + j - 50, "C"), .Cells(SRow(i) + j, "C")).Value
.Cells(k + i, "O").Resize(1, 50).Value = WorksheetFunction.Transpose(buf)
Next
j = j + 1
Next
End With
End Sub
No3の複数の行番号指定
Sub Test4()
Dim buf As Variant, tmp As Variant, SRow() As Variant
Dim i As Long, k As Long, j As Long
SRow = Array(53, 1050, 2050)
With Sheets("Sheet8")
.Cells(4, "O").Resize(6003, 50).ClearContents
For i = LBound(SRow) To UBound(SRow)
buf = .Range(.Cells(SRow(i) - 50, "C"), .Cells(SRow(i), "C")).Value
.Cells(4 + i, "O").Resize(1, 50).Value = WorksheetFunction.Transpose(buf)
For k = 4 + UBound(SRow) + 1 To 6003 Step UBound(SRow) - LBound(SRow) + 1
tmp = buf(LBound(buf, 1), 1)
For j = LBound(buf, 1) To UBound(buf, 1) - 1
buf(j, 1) = buf(j + 1, 1)
Next
buf(UBound(buf, 1), 1) = tmp
.Cells(k + i, "O").Resize(1, 50).Value = WorksheetFunction.Transpose(buf)
Next
Next
End With
End Sub
お礼
こんばんはkkkkkm さん。このソースもNo. 13と同様にすればよろしいのでしょうか?