0

所需的脚本是重新排列单元格,

Human:Annie
[Fruit]=Banana
[Fruit]=Mango
[Fruit]=Apple
Human:Jack
[Fruit]=Apple
Human:John
[Fruit]=Mango
[Fruit]=Papay

Human:Annie [Fruit]=Banana
Human:Annie [Fruit]=Mango
Human:Annie [Fruit]=Apple
Human:Jack  [Fruit]=Apple
Human:John  [Fruit]=Mango
Human:John  [Fruit]=Papaya

数据从 1 列更改为 2 列之前:A 列上的人类和水果数据之后:A 列上的人类数据和 B 列上的水果数据

4

1 回答 1

1

抱歉,我的 atm 没有 excel,只有 excel starter,所以没有 vba 可以帮你解决,但也许我可以让你开始。我将此作为答案发布,以便我可以格式化代码示例。希望这可以帮助您入门。只是一个提示如何开始。如果您无法对其进行排序,其他人可以稍后为您提供更好的答案。

Sub MoveValue()
Dim i As Integer
Dim x As Integer

x = ActiveSheet.UsedRange.Rows.Count

With ActiveSheet
    For i = 2 To x
        If Instr(.Cells(i, 1),"Human:") = 1 Then
            .Cells(i, 2).Value = .Cells(i, 1).Value
        End If
        If Instr(.Cells(i, 2),"[Fruit]") = 1 Then
            .Cells(i, 3).Value = .Cells(i, 2).Value
        End If

    Next i
End With

结束子

就像我说的那样,这将留下我期望的空白行,而不是一个完整的解决方案。

于 2013-07-20T08:35:06.540 回答