ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need SUBSTRING like function (https://www.excelbanter.com/excel-programming/419896-need-substring-like-function.html)

Greg Snidow

Need SUBSTRING like function
 
Greetings all. Let's say I have "AAAA - ABCD" in a cell. I need to extract
only the portion of text after the space after the hyphen. So, from the
example, I would need to extract "ABCD". With TSQL I can do it like this...

REVERSE(SUBSTRING(REVERSE('AAAA-ABCD'),1,4))

Or I can do...

RIGHT('AAAA - ABCD',4)

Are there any functions in Excel that would allow me to do this? In
reality, the field has a variable length before the hyphen, but the string
after the hypen is *always* = 8. Thank you.

Mike H

Need SUBSTRING like function
 
Try

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

Mike

"Greg Snidow" wrote:

Greetings all. Let's say I have "AAAA - ABCD" in a cell. I need to extract
only the portion of text after the space after the hyphen. So, from the
example, I would need to extract "ABCD". With TSQL I can do it like this...

REVERSE(SUBSTRING(REVERSE('AAAA-ABCD'),1,4))

Or I can do...

RIGHT('AAAA - ABCD',4)

Are there any functions in Excel that would allow me to do this? In
reality, the field has a variable length before the hyphen, but the string
after the hypen is *always* = 8. Thank you.


David

Need SUBSTRING like function
 
Greg
If the text string to be extracted from the right hand end is *always* 8
characters then you can use =RIGHT(A1,8)

"Greg Snidow" wrote:

Greetings all. Let's say I have "AAAA - ABCD" in a cell. I need to extract
only the portion of text after the space after the hyphen. So, from the
example, I would need to extract "ABCD". With TSQL I can do it like this...

REVERSE(SUBSTRING(REVERSE('AAAA-ABCD'),1,4))

Or I can do...

RIGHT('AAAA - ABCD',4)

Are there any functions in Excel that would allow me to do this? In
reality, the field has a variable length before the hyphen, but the string
after the hypen is *always* = 8. Thank you.


Greg Snidow

Need SUBSTRING like function
 
Thanks David and Mike. I guess I should have thought to check if Excel has a
RIGHT function. Most of the time my translating SQL into Excel is not so
gravy.

"David" wrote:

Greg
If the text string to be extracted from the right hand end is *always* 8
characters then you can use =RIGHT(A1,8)

"Greg Snidow" wrote:

Greetings all. Let's say I have "AAAA - ABCD" in a cell. I need to extract
only the portion of text after the space after the hyphen. So, from the
example, I would need to extract "ABCD". With TSQL I can do it like this...

REVERSE(SUBSTRING(REVERSE('AAAA-ABCD'),1,4))

Or I can do...

RIGHT('AAAA - ABCD',4)

Are there any functions in Excel that would allow me to do this? In
reality, the field has a variable length before the hyphen, but the string
after the hypen is *always* = 8. Thank you.



All times are GMT +1. The time now is 05:30 PM.

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