Excel 将数组拆分为多行

Excel 将数组拆分为多行,excel,csv,split,vba,Excel,Csv,Split,Vba,我在excel中有多个单元格,由70个点组成的数组。如何将数组中的每个数字拆分为自己的行 例如,目前我有一个数组,如下所示: A栏: [(42.07, -86.03), (42.074092, -87.031812000000002)] B栏: [0.00e+00,9.06e+02] C栏: [1.69e+01,1.72e+00] 所有这些数组都在同一行上。但是,我希望它显示在两个单独的行中: (42.07, -86.03) |0.00e+00 |1.69e+01 (42.074

我在excel中有多个单元格,由70个点组成的数组。如何将数组中的每个数字拆分为自己的行

例如,目前我有一个数组,如下所示:

A栏:

[(42.07, -86.03), (42.074092, -87.031812000000002)]
B栏:

[0.00e+00,9.06e+02]
C栏:

[1.69e+01,1.72e+00]
所有这些数组都在同一行上。但是,我希望它显示在两个单独的行中:

(42.07, -86.03)  |0.00e+00    |1.69e+01

(42.074092, -87.031812000000002) |9.06e+02    |1.72e+00

试试这样的

Sub ArrayToRows()
'Declare your array or arrays


'Array1 would correspond to your "Column A" array, I'm not sure of the names you want, _
'just change the variables to suit your needs

For i = LBound(Array) to UBound(Array)
    Cells(1,1).Value = Array1(i) & " " & Array2(i) & " " & Array3(i)
Next i

End Sub

正如@AlexP所说的,
Split
函数就是您在这里想要的,您可以将结果数组输出到工作表中

Sub ExpandToRows()

    Dim ColumnList As String, col As Variant, c As Range
    Dim OutputArray() As String, i As Long

    'list of columns to process
    ColumnList = "A,B,C" 'change to suit

    With Sheet1 'change to suit

        For Each col In Split(ColumnList, ",")

            Set c = .Cells(1, col) 'assume row 1, change to suit

            'determine if pair group
            If InStr(c.Value, "), (") > 0 Then

                'replace delimiter
                c.Value = Replace(c.Value, "), (", ")~(")

                'create array of values
                OutputArray = Split(c.Value, "~")

            Else '...or single values

                'create array of values
                OutputArray = Split(c.Value, ",")

            End If

            'write OutputArray to worksheet
            c.Resize(UBound(OutputArray) + 1) = Application.Transpose(OutputArray)

        Next col

    End With

End Sub

我已经添加了对组的处理,不过请注意,这假设列条目中的所有值都是一致的。

您是否已经查看了
Split()
?@AlexP正在查看此内容:但是,我不希望它以这种格式返回。