所需的脚本是重新安排单元格,
前
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栏上的水果数据
答案 0 :(得分:1)
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
End Sub
这将留下我希望的空行,就像我说的那样,而不是一个完整的解决方案。