ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Splitting text in a cell (https://www.excelbanter.com/excel-programming/369571-splitting-text-cell.html)

TheRook

Splitting text in a cell
 
I currently have cells populated with text and am wanting to split the text
from within the cell into two.

Example:

a1: contains 'SHEFFIELD UNITED:BLADES'
a2: contains 'SHEFFIELD WEDNESDAY:OWLS'
I am wanting to split the text for that every thing to the left of ':' is in
on cell and every thing that is to the right of ':' to be in another cell.

Can this be done?

Cheers

Gary''s Student

Splitting text in a cell
 
Use Text to Columns:

1. select the column
2. pull-down Data Text to Columns then select delimited then select the
colon
--
Gary's Student


"TheRook" wrote:

I currently have cells populated with text and am wanting to split the text
from within the cell into two.

Example:

a1: contains 'SHEFFIELD UNITED:BLADES'
a2: contains 'SHEFFIELD WEDNESDAY:OWLS'
I am wanting to split the text for that every thing to the left of ':' is in
on cell and every thing that is to the right of ':' to be in another cell.

Can this be done?

Cheers


Norman Jones

Splitting text in a cell
 
Hi TheRook,

If you require a VBA solution, try something like:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim arr As Variant

Set SH = ActiveSheet

With SH
Set rng = .Range("A1", .Cells(Rows.Count, "A").End(xlUp))
End With

For Each rCell In rng.Cells
With rCell
arr = Split(.Value, ":")
.Value = arr(0)
.Offset(0, 1) = arr(1)
End With
Next rCell
End Sub
'<<=============


---
Regards,
Norman



"TheRook" wrote in message
...
I currently have cells populated with text and am wanting to split the text
from within the cell into two.

Example:

a1: contains 'SHEFFIELD UNITED:BLADES'
a2: contains 'SHEFFIELD WEDNESDAY:OWLS'
I am wanting to split the text for that every thing to the left of ':' is
in
on cell and every thing that is to the right of ':' to be in another cell.

Can this be done?

Cheers




Tieu

Splitting text in a cell
 
See if this can help.
Assume your A1 cell contains: SHEFFIELD UNITED:BLADES

use formula in B1
=LEFT(A1,FIND(":",A1)-1)

use this formula in C1
=RIGHT(A1,LEN(A1) - FIND(":",A1))











All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com