【发布时间】:2015-11-06 07:28:04
【问题描述】:
我在 excel 中有一个文件如下所示:
我只想像这样转置数据:
A 0.02 B 0.01 C 0.01
我的代码不起作用,我使用复制粘贴方法但失败了。
我的代码:
Do Until y = 60
If xlApp.ActiveSheet.Cells(X, y).value = "" Then
xlApp.Range(xlApp.Cells(X + 1, y - 1), xlApp.Cells(X + 1, y - 1)).Select()
xlApp.Selection.copy()
xlApp.Range(xlApp.Cells(X, y), xlApp.Cells(X, y)).Select()
xlApp.ActiveSheet.Paste()
y = y + 1
ElseIf xlApp.ActiveSheet.Cells(X, y).value <> "" Then
y = y + 1
ElseIf y = 60 Then
y = 30
X = X + 1
Exit Do
End If
Loop
y 是第一列。如果有数据,则无需执行任何操作。如果没有数据,则在前面(下面)剪切数据并粘贴到旁边。
【问题讨论】: