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


Hello,

how do I pick up a cell (with strings) and extract 4 characters from
the 5th character from right side of the string. What function can I
use?

Please let me know. Thanks.


--
owl527
------------------------------------------------------------------------
owl527's Profile: http://www.excelforum.com/member.php...o&userid=20916
View this thread: http://www.excelforum.com/showthread...hreadid=482103

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default extract string

if i interpret your request correctly, i think this is what you need

=MID(A1,LEN(A1)-5,4)

--


Gary


"owl527" wrote in
message ...

Hello,

how do I pick up a cell (with strings) and extract 4 characters from
the 5th character from right side of the string. What function can I
use?

Please let me know. Thanks.


--
owl527
------------------------------------------------------------------------
owl527's Profile:
http://www.excelforum.com/member.php...o&userid=20916
View this thread: http://www.excelforum.com/showthread...hreadid=482103



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default extract string

looking at your request again, i'm not sure what you want. if there are 10
characters, and you want the 5th from the right, you would want the 6th,
7th, 8th and 9th characters.

this would do that

=MID(A1,LEN(A1)-4,4)

--


Gary


"owl527" wrote in
message ...

Hello,

how do I pick up a cell (with strings) and extract 4 characters from
the 5th character from right side of the string. What function can I
use?

Please let me know. Thanks.


--
owl527
------------------------------------------------------------------------
owl527's Profile:
http://www.excelforum.com/member.php...o&userid=20916
View this thread: http://www.excelforum.com/showthread...hreadid=482103



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default extract string

Building on Gary Keramidas suggestion I would also add a trim function to
the cell as so often you find spaces are at the end of strings (not visible)
and using the length function will be mis-interpreted.

=MID(TRIM(A1),LEN(TRIM(A1))-4,4)

The other issue you face is that if the cell is less than 5 chars in
length - you will get an invalid #VALUE!

So a conditional check in the function will help avoid that and give you
chance to show a controlled message eg

=IF(LEN(TRIM(A1))<5,"Too Short",MID(TRIM(A1),LEN(TRIM(A1))-4,4))

--
Cheers
Nigel



"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
looking at your request again, i'm not sure what you want. if there are 10
characters, and you want the 5th from the right, you would want the 6th,
7th, 8th and 9th characters.

this would do that

=MID(A1,LEN(A1)-4,4)

--


Gary


"owl527" wrote in
message ...

Hello,

how do I pick up a cell (with strings) and extract 4 characters from
the 5th character from right side of the string. What function can I
use?

Please let me know. Thanks.


--
owl527
------------------------------------------------------------------------
owl527's Profile:
http://www.excelforum.com/member.php...o&userid=20916
View this thread:

http://www.excelforum.com/showthread...hreadid=482103





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 value from a text string Dinesh Excel Worksheet Functions 11 April 30th 09 04:29 AM
Extract from string mark Excel Discussion (Misc queries) 2 August 8th 06 12:38 PM
Extract text from String Dan Excel Worksheet Functions 8 July 1st 06 12:39 PM
Extract sub string sixbeforedawn Excel Worksheet Functions 2 October 24th 05 09:50 AM
extract string dreamer[_17_] Excel Programming 2 June 1st 04 12:50 PM


All times are GMT +1. The time now is 04:51 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"