Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Extract one character

Column C in one worksheet has text strings, from Row 2 thru Row 676. These
strings can be two, three, or four words. I need a formula to extract the
first character to the right of the last space.
For example,

Rts is unpaid - u
Ldpq to be quoted - q
Will call - c

Thanks for the help
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Extract one character

One way is to use a helper column and a formula like this:

=LEFT(TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99)),1)
and drag down



Carl wrote:

Column C in one worksheet has text strings, from Row 2 thru Row 676. These
strings can be two, three, or four words. I need a formula to extract the
first character to the right of the last space.
For example,

Rts is unpaid - u
Ldpq to be quoted - q
Will call - c

Thanks for the help


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Extract one character

Thank you, works like a charm.
Now I need to figure out how it does the job???

"Dave Peterson" wrote:

One way is to use a helper column and a formula like this:

=LEFT(TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99)),1)
and drag down



Carl wrote:

Column C in one worksheet has text strings, from Row 2 thru Row 676. These
strings can be two, three, or four words. I need a formula to extract the
first character to the right of the last space.
For example,

Rts is unpaid - u
Ldpq to be quoted - q
Will call - c

Thanks for the help


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Extract one character

if c2 holds
abc def
then
=SUBSTITUTE(C2," ",REPT(" ",99))
would look like:
abc(99 space characters)def

So
=RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99))
would give the right most 99 characters:
(96 space characters)def
(96 since def is just 3 characters)

=trim() removes the leading/trailing (and duplicated internal spaces!) in the
string:

so
=TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99))
is just
def

and
=left(..., 1)
returns the first character of that def (just d).

I didn't come up with that =substitute() trick, but it works very nice under
certain conditions.

Carl wrote:

Thank you, works like a charm.
Now I need to figure out how it does the job???

"Dave Peterson" wrote:

One way is to use a helper column and a formula like this:

=LEFT(TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99)),1)
and drag down



Carl wrote:

Column C in one worksheet has text strings, from Row 2 thru Row 676. These
strings can be two, three, or four words. I need a formula to extract the
first character to the right of the last space.
For example,

Rts is unpaid - u
Ldpq to be quoted - q
Will call - c

Thanks for the help


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 361
Default Extract one character

Thank you very much for the time spent in explaining the solution.
As always you efforts are greatly appreciated.

"Dave Peterson" wrote:

if c2 holds
abc def
then
=SUBSTITUTE(C2," ",REPT(" ",99))
would look like:
abc(99 space characters)def

So
=RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99))
would give the right most 99 characters:
(96 space characters)def
(96 since def is just 3 characters)

=trim() removes the leading/trailing (and duplicated internal spaces!) in the
string:

so
=TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99))
is just
def

and
=left(..., 1)
returns the first character of that def (just d).

I didn't come up with that =substitute() trick, but it works very nice under
certain conditions.

Carl wrote:

Thank you, works like a charm.
Now I need to figure out how it does the job???

"Dave Peterson" wrote:

One way is to use a helper column and a formula like this:

=LEFT(TRIM(RIGHT(SUBSTITUTE(C2," ",REPT(" ",99)),99)),1)
and drag down



Carl wrote:

Column C in one worksheet has text strings, from Row 2 thru Row 676. These
strings can be two, three, or four words. I need a formula to extract the
first character to the right of the last space.
For example,

Rts is unpaid - u
Ldpq to be quoted - q
Will call - c

Thanks for the help

--

Dave Peterson


--

Dave Peterson

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
Extract numeric characters plus one character... KLZA Excel Worksheet Functions 14 February 4th 09 03:23 AM
Extract a text string based on character kgiraffa Excel Worksheet Functions 5 March 14th 08 12:54 AM
Excel-Match 1st text character in a string to a known character? bushlite Excel Worksheet Functions 2 January 15th 07 06:36 PM
extract data up to a certain character markahpi Excel Worksheet Functions 5 August 16th 06 03:38 AM
Extract Unique Values, Then Extract Again to Remove Suffixes Karl Burrows Excel Discussion (Misc queries) 23 June 25th 05 10:37 PM


All times are GMT +1. The time now is 05:57 AM.

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"