ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help with Text to Column in a macro. (https://www.excelbanter.com/excel-programming/366297-need-help-text-column-macro.html)

Viking

Need help with Text to Column in a macro.
 
I am hoping that someone can offer help with this matter.

I have the following text that I need to break into separate columns to
get the sentences separated:
"1.2.3 This is an example. That I need to break down"

What I get when I do a texttocolumn using the "." as the separator:
"1" "2" "3" "This is an example" "That I need to
break down"

What I am trying to get is:
"1.2.3" "This is an example" "That I need to break down"

Is there someway of breaking the "1.2.3" out first?

Thanks for any help.
Troy Vincent


Charlie

Need help with Text to Column in a macro.
 
Dim s As String
Dim FirstPart As String
Dim OtherParts() As String

s = "1.2.3 This is an example. That I need to break down"
FirstPart = Split(s, " ", 2)(0)
OtherParts = Split(Split(s, " ", 2)(1), ".")

FirstPart returns a single string
OtherParts returns a (zero-based) array


"Viking" wrote:

I am hoping that someone can offer help with this matter.

I have the following text that I need to break into separate columns to
get the sentences separated:
"1.2.3 This is an example. That I need to break down"

What I get when I do a texttocolumn using the "." as the separator:
"1" "2" "3" "This is an example" "That I need to
break down"

What I am trying to get is:
"1.2.3" "This is an example" "That I need to break down"

Is there someway of breaking the "1.2.3" out first?

Thanks for any help.
Troy Vincent



Viking

Need help with Text to Column in a macro.
 
Charlie

That worked great for the most part. When I ran a test to the text
that I am working with I found that the following happened.

when the numbers changed to something like "1.4.0 This is an example.
That I need to break down"

I get "1.4" "This is an example" "That I need to break down"

It is droping the .0
Any Ideas on how I would be able to keep it.
Thanks in advance
Troy Vincent

Charlie wrote:
Dim s As String
Dim FirstPart As String
Dim OtherParts() As String

s = "1.2.3 This is an example. That I need to break down"
FirstPart = Split(s, " ", 2)(0)
OtherParts = Split(Split(s, " ", 2)(1), ".")

FirstPart returns a single string
OtherParts returns a (zero-based) array


"Viking" wrote:

I am hoping that someone can offer help with this matter.

I have the following text that I need to break into separate columns to
get the sentences separated:
"1.2.3 This is an example. That I need to break down"

What I get when I do a texttocolumn using the "." as the separator:
"1" "2" "3" "This is an example" "That I need to
break down"

What I am trying to get is:
"1.2.3" "This is an example" "That I need to break down"

Is there someway of breaking the "1.2.3" out first?

Thanks for any help.
Troy Vincent




Charlie

Need help with Text to Column in a macro.
 
That's unusual. Could you post the exact code and data you are using? I
will be hitting the road shortly but someone else may be able to figure it
out.

"Viking" wrote:

Charlie

That worked great for the most part. When I ran a test to the text
that I am working with I found that the following happened.

when the numbers changed to something like "1.4.0 This is an example.
That I need to break down"

I get "1.4" "This is an example" "That I need to break down"

It is droping the .0
Any Ideas on how I would be able to keep it.
Thanks in advance
Troy Vincent

Charlie wrote:
Dim s As String
Dim FirstPart As String
Dim OtherParts() As String

s = "1.2.3 This is an example. That I need to break down"
FirstPart = Split(s, " ", 2)(0)
OtherParts = Split(Split(s, " ", 2)(1), ".")

FirstPart returns a single string
OtherParts returns a (zero-based) array


"Viking" wrote:

I am hoping that someone can offer help with this matter.

I have the following text that I need to break into separate columns to
get the sentences separated:
"1.2.3 This is an example. That I need to break down"

What I get when I do a texttocolumn using the "." as the separator:
"1" "2" "3" "This is an example" "That I need to
break down"

What I am trying to get is:
"1.2.3" "This is an example" "That I need to break down"

Is there someway of breaking the "1.2.3" out first?

Thanks for any help.
Troy Vincent






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

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