我需要从具有此布局的Excel工作表中导入数据:
我想把它转换成这样一个简单的表:
这有什么简单的方法吗?
答案 0 :(得分: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