PDA

View Full Version : Split Multiline Cell text Into Multiple Rows



john3j
05-20-2015, 10:49 AM
Cell A5 contains the following multiline text:

This
Is
A
Test

I am trying to figure out how to get the following:

Range("A5").Value = "This"
Range("A6").Value = "Is"
Range("A7").Value = "A"
Range("A8").Value = "Test"

Is there a way to select the contents of a multi line cell and paste it so that each line is in a new row?

mancubus
05-20-2015, 12:59 PM
Sub vbax_52645_Split_Write()

Dim SplitText

SplitText = Split(Range("A5").Value, vbLf)
Range("A5").Resize(UBound(SplitText) + 1).Value = Application.Transpose(SplitText)

End Sub

john3j
05-21-2015, 06:08 AM
That is EXACTLY what I was looking for! Thank you so much!

mancubus
05-21-2015, 07:16 AM
you are welcome.

please mark the thread as solved from Thread Tools for future references.