Home » excel » excel – How to split string into separate cells

excel – How to split string into separate cells

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have this string that consists of stockmarket data:

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

What one can see is that there are 8 blocks of data in one string and that these blocks are separated with a space.

What I want to do is to split every block of data an place it into separate cells in Excel.

How to&Answers:

There is an option called “Text to columns”, this will solve your problem. Using this tool it’s possible to define what is your text delimiter (;, ,, and so on) or what is the size of your text block.

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

If you want a solution based on VBA script you can take a look at Excel Macro – Comma Separated Cells to Rows

Answer:

I had to think a bit on mehow’s upper range eval. I came up with this for my useful snippets:

        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