2017-06-20 7 views
0

Ich habe mehrere Zellen in Excel, die aus einem Array von 70 Punkten besteht. Wie kann ich jede dieser Zahlen im Array in eine eigene Zeile aufteilen?Ein Array in mehrere Zeilen aufteilen

Zum Beispiel haben derzeit I ein Array als so:

Spalte A:

[(42.07, -86.03), (42.074092, -87.031812000000002)] 

Spalte B:

[0.00e+00,9.06e+02] 

Spalte C:

[1.69e+01,1.72e+00] 

All dieser Arrays sind gleich Reihe. Allerdings möchte ich es als so in zwei getrennten Reihen zeigen:

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

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

Haben Sie sich 'Split()' angesehen? –

+0

@AlexP Blick auf das gerade jetzt: https://www.techonthenet.com/excel/formulas/split.php Ich möchte es jedoch nicht in diesem Format zurückgeben. – taa06

Antwort

0

als @AlexP sagte der Split Funktion ist das, was Sie hier wollen, können Sie dann ausgegeben das resultierende Array in das Arbeitsblatt

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 

ich im Umgang mit für die Paargruppen obwohl Anmerkung hinzugefügt haben, übernimmt diese alle Werte in einem Spalteneintrag konsistent sind.

0

Probieren Sie etwas wie dieses

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 
Verwandte Themen