split problem

×

×לי

Hi all,

I am interesting to break a string with spaces into an array with substrings
and to have it in the same cell.
for example:
dim MyString as string
MyString = range("A1").value ' range("A1").value = "Good morning"
range("A1").value = split(MyString, " ").

The problem is that instead of:
Good
morning

as range("A1").value I get only: morning.

Please help me to fix it!

Thanks

Eli
 
J

Jacob Skaria

'Once you split it returns an array; so that you could try

Dim MyString As String
MyString = Range("A1").Value
Range("A1:B1") = Split(MyString, " ")

'Instead ..if you mean to replace a splace with carriage return then try
Range("A1") = Replace(Range("A1"), " ", vbLf)
 
×

×לי

Many thanks!

Jacob Skaria said:
'Once you split it returns an array; so that you could try

Dim MyString As String
MyString = Range("A1").Value
Range("A1:B1") = Split(MyString, " ")

'Instead ..if you mean to replace a splace with carriage return then try
Range("A1") = Replace(Range("A1"), " ", vbLf)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top