Case Object Equation Contents
293 asdg D0799* (1-(S0191+S0439+S0960+S0560)) * (1-(C0121+C0122)) S0439 S0960 S0560
296 iknm D0792* (1-(S0191+S0565+S0567+S0960+S0560)) S0565 S0567 S0960 S0560
298 yiol D0191* (1-(S0191+S0439+S2820+S0960+S0560)) S0439 S2820 S0960 S0560
我试图将上述数据转移到下面的数据。行和列会有更多。
Case Object Equation contents
293 asdg D0799* (1-(S0191+S0439+S0960+S0560)) * (1-(C0121+C0122)) S0439
293 asdg D0799* (1-(S0191+S0439+S0960+S0560)) * (1-(C0121+C0122)) S0960
293 asdg D0799* (1-(S0191+S0439+S0960+S0560)) * (1-(C0121+C0122)) S0560
296 iknm D0792* (1-(S0191+S0565+S0567+S0960+S0560)) S0565
296 iknm D0792* (1-(S0191+S0565+S0567+S0960+S0560)) S0567
296 iknm D0792* (1-(S0191+S0565+S0567+S0960+S0560)) S0960
296 iknm D0792* (1-(S0191+S0565+S0567+S0960+S0560)) S0560
298 yiol D0191* (1-(S0191+S0439+S2820+S0960+S0560)) S0439
298 yiol D0191* (1-(S0191+S0439+S2820+S0960+S0560)) S2820
298 yiol D0191* (1-(S0191+S0439+S2820+S0960+S0560)) S0960
298 yiol D0191* (1-(S0191+S0439+S2820+S0960+S0560)) S0560
宏是
Sub EquationSegment()
Dim Dic As Object: Set Dic = CreateObject("Scripting.Dictionary")
Dim cl As Range, Key As Variant, i&
i = 1
For Each cl In Range("c2:af" & Cells(Rows.Count, "a").End(xlUp).Row)
Dic.Add i & ":" & Cells(cl.Row, 1).Value, cl.Value
i = i + 1
Next cl
i = 2: [an1] = "Equation": [ao1] = "contents"
For Each Key In Dic
Cells(i, "an").Value = Split(Key, ":")(1)
Cells(i, "ao").Value = Dic(Key)
i = i + 1
Next Key
Set Dic = Nothing
End Sub
我只能转移2列。任何人都可以帮我解决范围问题吗?
答案 0 :(得分:0)
字典只能存储键值对,因此这不是一种很好的方法。您最终必须加入然后拆分字符串。你可以更好地使用嵌套循环。
401af4-401000+400