Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Splitting a String


I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=511600

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Splitting a String

maybe this

=RIGHT(longString,(LEN(longString)-FIND(" ",longString,1)))

--


Gary


"AMK4" wrote in message
...

I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:
http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=511600



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Splitting a String

if the original string is in A1
the formula you show in A2
in A3 as an example

=Right(A1,len(A1)-(len(A2)+1))

or if you want to us find to find it again

=Right(A1,len(A1)-Find(" ",A1))

or you can use the mid function

=MID(A1,FIND(" ",A1)+1,LEN(A1))


--
Regards,
Tom Ogilvy



"AMK4" wrote in message
...

I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile:

http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=511600



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Splitting a String

There are a couple of ways to do this.

lastWord = right(longString, len(longString) - Find(" ", longString) + 1)

or

lastWord = mid(longString, Find(" ", longString) + 1, 256)

--
HTH...

Jim Thomlinson


"AMK4" wrote:


I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=511600


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Splitting a String

Here is a short one:

rest = Mid(longString,1+len(firstWord ))

then use TRIM if you want to get rid of noise spaces.

Regards,
Antonio Elinon

"AMK4" wrote:


I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


--
AMK4
------------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...o&userid=19143
View this thread: http://www.excelforum.com/showthread...hreadid=511600




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Splitting a String

On Sun, 12 Feb 2006 22:12:43 -0600, AMK4
wrote:


I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


And another method:

With your formula above in B1:

=SUBSTITUTE(longString,B1&" ","")


--ron
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Splitting a String

This will not work as you could end up removing similar occurences of the
firstWord in the remaining portion, eg. "aa bbb aa xxx" will have an
incorrect remainder of "bbb xxx".

Regards,
Antonio Elinon

"Ron Rosenfeld" wrote:

On Sun, 12 Feb 2006 22:12:43 -0600, AMK4
wrote:


I need to split a string into two parts: the first word, and whatever's
left of the remaining string. I do this to capture the first word:
Code:
--------------------
firstWord = Left(longString, Find(" ", longString) - 1)
--------------------
... however I don't know what's the easiest (smartest?) way to figure
out the remaining part of the string.


And another method:

With your formula above in B1:

=SUBSTITUTE(longString,B1&" ","")


--ron

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Splitting a String

On Mon, 13 Feb 2006 14:19:27 -0800, "Antonio Elinon"
wrote:

This will not work as you could end up removing similar occurences of the
firstWord in the remaining portion, eg. "aa bbb aa xxx" will have an
incorrect remainder of "bbb xxx".

Regards,
Antonio Elinon


Thanks for pointing that out.
--ron
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Splitting a String

On Mon, 13 Feb 2006 14:19:27 -0800, "Antonio Elinon"
wrote:

This will not work as you could end up removing similar occurences of the
firstWord in the remaining portion, eg. "aa bbb aa xxx" will have an
incorrect remainder of "bbb xxx".

Regards,
Antonio Elinon



Thanks for pointing that out.

The proper formula, using the SUBSTITUTE method, should be:

=SUBSTITUTE(longString,B1&" ","",1)


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
String splitting for inconsistent strings Richard Excel Worksheet Functions 3 June 22nd 06 03:55 AM
Splitting a concatenated string into separate rows... Natarajan Excel Worksheet Functions 1 May 4th 06 05:57 PM
Splitting a text string into string and number mcambrose Excel Discussion (Misc queries) 4 February 21st 06 03:47 PM
Splitting Character String mcertini Excel Worksheet Functions 2 September 12th 05 09:41 AM
Splitting string into letters and numbers Foss[_2_] Excel Programming 2 February 3rd 05 10:35 AM


All times are GMT +1. The time now is 08:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"