View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default how to split 2 or 3 pieces name in 1 cell into 2 or 3 cells

just to expand on kalpesh's response, his solution is vba since this is a
programming newsgroup.

try this code. it assumes your names are in column A starting in Row1 on sheet1
and the names are split in columns B, C & D in the same row

just change the references to whatever you need

Sub split_text()
Dim data As Variant
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow
data = Split(Range("A" & i).Value, " ")
ws.Range("B" & i) = data(0)
If UBound(data) = 2 Then
ws.Range("C" & i) = data(1)
ws.Range("D" & i) = data(2)
Else
ws.Range("D" & i) = data(1)
End If
Next
End Sub
--


Gary


"Frank Situmorang" wrote in message
...
Thanks Kalpesh for your quick response, however I have tried to look all
excel function, I can not found split function, could you explain again on
how can I handle it?

Thanks very much

--
H. Frank Situmorang


"Kalpesh" wrote:

Frank,

You can use Split function to break the string into pieces seperated
by space.

So, a string with Rone Aprilia Gultom will return an array with length
3
e.g. data = Split("Rona Aprilia Gultom", " ")
data(0) - will return Rona
data(1) - will return Aprilia
data(2) - will return Gultom

The length of array will change depending upon the spaces inside the
name.
I am assuming, things are seperated by space.

HTH
Kalpesh




On Dec 18, 10:46 am, Frank Situmorang wrote:
Hello,

I want to finetuning my chruch records membership
With 500 members some names are 2 or 3 pieces words and now I want to put
them into separate names since I want to build a Access database instead of
excell

this is example of my problem
In excel iin one Cell
Rona Aprilia Gultom, I want to separate it into 3 Cell
Fuirst Name: Rona
Middle Name: Aprilia
Last Name: Gultom

My problem some is 2 pieces and some are 3 and the length of the name is
variable so I can not use Mid function in this matter.

What is certain is there is alwasy "space" between the words of the name

Can anyone help me how to do splitting this names?

Thanks in advance,

Frank

--
H. Frank Situmorang