我正在尝试将列值转换为行并将其中一个单元格中的值拆分为行。这是我正在尝试做的事情:
输入数据:
09/20/2013
$240
Item1, Item2, Item3
输出数据:
09/20/2013 $80 Item1
09/20/2013 $80 Item2
09/20/2013 $80 Item3
该值取决于项目的数量。它是 80 美元 * 项目数。我必须拆分项目的单元格并将它们转换成行。我无法使用宏来做到这一点。
也许有点矫枉过正,但试试这个:
Sub SplitUp()
Dim rng As Range
Set rng = [A1:A3]
Dim sx() As String
sx = Split(rng(3, 1).Value, ",")
Dim cntr As Integer
cntr = 1
Dim money As Long
money = rng(2, 1).Value / (UBound(sx) + 1)
For i = LBound(sx) To UBound(sx)
Range("C" & cntr).Value = rng(1, 1) & " $" & money & " " & sx(i)
cntr = cntr + 1
Next
End Sub
结果如下所示: