如何将string拆分成单独的单元格

我有这个由股票市场数据组成的string:

162,90 1,10 0,67 162,80 163,00 164,30 162,80 157087560 

我们可以看到,一个string中有8个数据块,而且这些数据块之间有一个空格。

我想要做的是将每个数据块分割到Excel中的单独单元格中。

有一个选项称为“文本到列”,这将解决您的问题。 使用这个工具可以定义什么是你的文本分隔符( ;等等)或什么是你的文本块的大小。

http://office.microsoft.com/en-001/excel-help/split-text-into-different-cells-HA102809804.aspx

如果你想要一个基于VBA脚本的解决scheme,你可以看看Excel Macro – 逗号分隔单元格到行

我不得不稍微思考一下上面的范围。 我想出了这个有用的片段:

  For Each c In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row) ' find last row in column A with data: ' from the bottom ("A" & Rows.Count) ' proceed Up to find last populated Cell in a given column (A) Next c For Each c In Range("A1:A" & Range("A1").End(xlDown).Row) ' from A1 ' from top proceed down to row above the first unoccupied cell Next c