Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return the characters after Nth character in a string

Tags:

excel

vba

I need help! Can someone please let me know how to return the characters after the nth character?

For example, the strings I have is "001 baseball" and "002 golf", I want my code to return baseball and golf, not the number part. Since the word after the number is not always the same length, I cannot use = Right(String, n)

Any help will be greatly appreciated

like image 631
user2683996 Avatar asked Sep 18 '13 17:09

user2683996


People also ask

How do I extract text before and after a specific character in Excel?

To get text following a specific character, you use a slightly different approach: get the position of the character with either SEARCH or FIND, subtract that number from the total string length returned by the LEN function, and extract that many characters from the end of the string.

How do you extract data from a cell after a character?

Extract text before or after space with formula in Excel Select a blank cell, and type this formula =LEFT(A1,(FIND(" ",A1,1)-1)) (A1 is the first cell of the list you want to extract text) , and press Enter button.


2 Answers

If your numbers are always 4 digits long:

=RIGHT(A1,LEN(A1)-5) //'0001 Baseball' returns Baseball

If the numbers are variable (i.e. could be more or less than 4 digits) then:

=RIGHT(A1,LEN(A1)-FIND(" ",A1,1)) //'123456 Baseball’ returns Baseball
like image 137
Alex P Avatar answered Oct 27 '22 01:10

Alex P


Mid(strYourString, 4) (i.e. without the optional length argument) will return the substring starting from the 4th character and going to the end of the string.

like image 25
rory.ap Avatar answered Oct 27 '22 01:10

rory.ap