所以我在excel中拥有值的单元格。我希望他们分开并获得所有单词的列表。
EDF, renewables, nuclear, France, USA
red, yellow
到
EDF
renewables
nuclear
France
USA
red
yellow
答案 0 :(得分:0)
这似乎有效。
Option Explicit
Sub splitDown()
Dim i As Long, arr As Variant
With Worksheets(1)
For i = .Cells(.Rows.Count, "A").End(xlUp).Row To 1 Step -1
If CBool(InStr(1, .Cells(i, "A").Value2, ", ")) Then
arr = Split(.Cells(i, "A").Value2, ", ")
.Cells(i + 1, "A").Resize(UBound(arr), 1).EntireRow.Insert
.Cells(i, "A").Resize(UBound(arr) + 1, 1) = Application.Transpose(arr)
End If
Next i
End With
End Sub