我被告知宏可能是我能够解决这个问题的唯一方法,而且我对vba或excel宏一点也不熟悉。提前感谢您的帮助..
我遇到的情况是我从电子表格中的一个系统接收数据
1 E111 Project Location Department Company
2 E222 Project Location Department Company
3 E333 Project Location Department Company
我需要像这样显示每个组织类型一行,以及要加载到另一个系统的行标识符。
1 Project
1 Location
1 Dept
2 Project
2 Location
2 Dept
3 Project
3 Location
3 Dept
答案 0 :(得分:1)
如果您想按照逻辑转置数据,请尝试以下方法:
Sub TransposeColumns()
Dim srcwsh As Worksheet, dstwsh As Worksheet
Dim i As Integer, j As Integer
Set srcwsh = ThisWorkbook.Worksheets("Sheet1")
Set dstwsh = ThisWorkbook.Worksheets("Sheet2")
'define initial rows
i = 2 'source worksheet
j = 2 'destination worksheet
Do While srcwsh.Range("A" & i) <> ""
srcwsh.Range("A" & i).Copy dstwsh.Range("A" & j & ":A" & j + 2)
srcwsh.Range("C" & i & ":E" & i).Copy
dstwsh.Range("B" & j).PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, True
j = j + 3
i = i + 1
Loop
Set dstwsh = Nothing
Set srcwsh = Nothing
End Sub
您必须根据需要更改代码。