2011-06-20 15 views

答えて

1

ここではあなたのデータをループする簡単なマクロです

Sub Demo() 
    Dim vSrc As Variant 
    Dim vDst As Variant 
    Dim i As Long, r As Long, c As Long 

    vSrc = Worksheets("SourceData").UsedRange 
    ReDim vDst(1 To UBound(vSrc, 1) * UBound(vSrc, 2)/3, 1 To 3) 
    i = 1 
    For c = 1 To UBound(vSrc, 2) 
     For r = 1 To UBound(vSrc, 1) - 2 Step 3 
      vDst(i, 1) = vSrc(r, c) 
      vDst(i, 2) = vSrc(r + 1, c) 
      vDst(i, 3) = vSrc(r + 2, c) 
      i = i + 1 
     Next 
    Next 
    Worksheets("DestData").Cells(2, 1).Resize(UBound(vDst), 3) = vDst 
End Sub 
関連する問題