ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   splitting information into 2 cells (https://www.excelbanter.com/excel-programming/350071-splitting-information-into-2-cells.html)

Kelly********

splitting information into 2 cells
 
Is there a way to split information that is in 1 cell on sheet 1 into 2 cells
on sheet 2
Sheet 1 cell(K2) might have something like this 774-5992 / 647-4364 or
321-774-5992 / 647-4364 I want it to be copied to sheet 2 cells (A7) & (B7)
774-5992 would be in A7, 647-4364 would be in B7. If (K2 only has one set of
#s (774-5992) then nothing happens. The cells with 2 sets of #s always has /
as a divider.

I would like to beable to insert the code to make this happen into a
recorded macro. that copies other cell information from sheet 1 into sheet 2.

Stefi

splitting information into 2 cells
 
Hu Kelly,

Try this function:

Public Function SplitStr(StrToSplit As String, SplitChar As String, PartNo
As Integer) As String
SplitStr = IIf(PartNo = 1, Left(StrToSplit, InStr(StrToSplit, SplitChar)
- 1), _
Mid(StrToSplit, InStr(StrToSplit, SplitChar) + 1))
End Function

Use it like this:

Range("A7") = SplitStr(Range("K2"), "/", 1)
Range("B7") = SplitStr(Range("K2"), "/", 2)

Regards,
Stefi

€˛Kelly********€¯ ezt Ć*rta:

Is there a way to split information that is in 1 cell on sheet 1 into 2 cells
on sheet 2
Sheet 1 cell(K2) might have something like this 774-5992 / 647-4364 or
321-774-5992 / 647-4364 I want it to be copied to sheet 2 cells (A7) & (B7)
774-5992 would be in A7, 647-4364 would be in B7. If (K2 only has one set of
#s (774-5992) then nothing happens. The cells with 2 sets of #s always has /
as a divider.

I would like to beable to insert the code to make this happen into a
recorded macro. that copies other cell information from sheet 1 into sheet 2.


Bob Phillips[_6_]

splitting information into 2 cells
 
Just use DataText To Columns and use / as a delimiter.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Kelly********" wrote in message
...
Is there a way to split information that is in 1 cell on sheet 1 into 2

cells
on sheet 2
Sheet 1 cell(K2) might have something like this 774-5992 / 647-4364 or
321-774-5992 / 647-4364 I want it to be copied to sheet 2 cells (A7) &

(B7)
774-5992 would be in A7, 647-4364 would be in B7. If (K2 only has one set

of
#s (774-5992) then nothing happens. The cells with 2 sets of #s always has

/
as a divider.

I would like to beable to insert the code to make this happen into a
recorded macro. that copies other cell information from sheet 1 into sheet

2.




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

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