Comments on: Excel substring: how to extract text from cell

Although there is no such thing as Substring function in Excel, there exist three Text functions to extract text of a given length from a cell. Additionally, there are FIND and SEARCH functions to get a substring before or after a specific character. Continue reading

Comments page 8. Total comments: 445

  1. Extremely useful website! Thanks for sharing.

  2. How do I extract a specific character from a word?
    eg - if the word is wate%r, how do i extract "%" from it. So if there is a list of words of different length, and different placements of "%", I need one formula which will extract the "%" from it. Result should be "%" for all words.

    1. Hello!
      If I understand your task correctly, the following formula should work for you:

      =IF(ISNUMBER(FIND("%",A1,1)),"%","")

      Hope this is what you need.

      1. Thank you! this worked..

  3. Hello,

    I have a column in column A that has movie names and release dates as one text string. How do separate the movie name from the long date? I've figured out how to extract when it's only the movie name and date together, but sometimes the movie synopsis follows the date in the same column. This is where it stumps me. To split the movie and the date, when it's only those two items, I have a column for each month, and have used =iferror(left(a2,find($f$1,a2)-1),"") where f1 is the heading for January, g2 for February, h3 for March and so on through December. This has successfully given me the movie name, but in the column i have for the date, I have this formula (=text, e2,"mmmm dd, yyyy"). When the synopsis follows the date, I'm left with the date followed by a paragraph of text in that column that I can't seem to get rid of.

    Thank you,

    Mike

    1. Hello!
      Unfortunately, without seeing your data it hard to give you advice.
      Please provide me with an example of the source data and the expected result.
      It’ll help me understand your request better and find a solution for you.

      1. The formatting of my reply should look nothing like that. I want three columns. The first column is for example: The King's ManSeptember 18, 2020 As a collection of history's worst tyrants and criminals....

        The second column, I want to output just the movie name

        The third column I want to output only the date in long format. I don't want the text that follows the date in the source column kept at all. I want to strip that and toss it away.

      2. is there a way to upload a snippet of my worksheet so you can see it? In essence I have one column that I want to split the date from the text. The source column would be formatted like:
        Source Result Result
        Column A Column B Column C
        Movie nameJuly 22, 2020 Extraneous text Movie name July 22, 2020
        Movie nameAugust 8,2020 Movie name August 8, 2020
        Movie nameSeptember 4, 2020 Alphanumeric Movie name September 4, 2020
        Movie nameMay 1, 2021 Text text text text Movie name May 1, 2021

  4. I want to put first four alphabets in last in the same column.
    For Example want to change 4296HR55U to HR55U4296.
    Pls help.
    Regards

    1. Hello!
      If I understand your task correctly, the following formula should work for you:

      =REPLACE(D1,1,4,"")&LEFT(D1,4)

      I hope this will help

  5. Hi Anyone can help me out extract "AHU" from "LEGTAIFIYA TVS AHU-02-A-1M"

    1. Hello!
      The information presented to you is not enough to give you advice.
      Need to determine if "AHU" appears in the text? Or do you need to extract text from some position?
      Please describe your problem in more detail. It’ll help me understand it better and find a solution for you. Thank you.

  6. May I know how to extract 黃惠玲 from string "Wong Wai Ling (黃惠玲)" in cell A1?
    Thanks & Best Regards,
    Terry

    1. Hello Terry!
      If I understand your task correctly, the following formula should work for you:

      =MID(A2,FIND("(",A2,1)+1, FIND(")",A2,1) - FIND("(",A2,1)-1)

      I hope this will help

  7. I am trying to figure out what formula I would need to use to extract a value from the middle of a string. The length of the value can change so I was looking for a function that allows me to look up between 2 different characters including a character that repeats. An example: What is the area of a 60 degree circle when the bending radius is 1/8 round to the nearest tenth.
    I want to extract the 1/8, what formula would I need to use

    1. Hello Norma!
      I think that according to your requirements it’s impossible to make a formula. The fact is that in the middle of the line is also the number 60. In addition, the character "/" is not a number.

  8. LEFT(cell, SEARCH("char", cell)-1) is wrong, its ; instead of ,

    1. Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail? Thank you!

  9. I just have to say Thank you so much for this article!

  10. I want to extract the contents of all cells containing a certain substring delimited by a "," or ";".
    For example:
    Cell A1 contains "0", Cell B1 contains "index:1", Cell C1 contains "0", Cell D1 contains "index:2"
    I want to find all the cells that contain the word "index" and when found, to extract the full contents of the cell into one cell. In the above example, I am looking for a return value index:1,index:2.

    How can I do that?

  11. I'm trying to enter the date in one cell (01-Jan-2020) column A and want excel to split it into three columns B,C,D (day, month and year). could you please help me in formula

  12. Dear can somebody help me to extract Q amount from below string,
    LON AC YTO Q125 Q100 AC YMQ Q125 AC YYZ

    Thanks

  13. Thank you!

  14. i want to extract only LHS or RHS from the text, how to do it
    i.e 1234 LHS WERT SERT
    1234 RHS WERT SDFR

  15. How do I cut the specific content from a cell?

  16. Hi, I have long texts in the excel cells and I would always need to extract only the Impacted country which differs from cell to cell (in the example below it would be India). Only the text before the country is constant "Impacted Country (For multiple countries select global) = "

    Can anybody help how can I do that?

    Text in 1 excel cell is for example as below:
    ---------------------- USER ENTERED DATA ----------------------
    Operating System = Windows 10
    Impacted Country (For multiple countries select global) = India
    Idoc Number: = (NOT ENTERED)
    GSAP Transaction Code: = (NOT ENTERED)
    EMCS Table = (NOT ENTERED)
    Document Number: e.g. BOL, Nom key, LRN# = (NOT ENTERED)
    EMCS Dashboard Status = (NOT ENTERED)
    Interface ID: = (NOT ENTERED)
    Load date/Time = (NOT ENTERED)

    Thank you for your help in advance!

  17. How to extract the texts between 3rd and 4th or in case (last - 1) texts between instances of a character

  18. I have a long text (which is a extraction of narration from accounting entries) which contains month and year like "salaries for the month of FEB 2018", "cheque number 123456 paid to Mr. Rajan towards salary for the month of Feb 2018". Now i want to extract the month and year alone. Can somebody help me.

  19. Hi, what should be the formula if I want to extract text from the cell but the result doesn't match the character that I am looking for? the best scenario is as below:
    14933 - Cologne West
    15116 - Tador East
    12345 - Cologne East
    45678 - Tador South
    36789 - Sucat
    15674 - Alabang

    From the list, I want to extract only the text but with a condition that if it is not "Tador", just copy the location, otherwise just put "Tador". I have tried several formulas but to no avail.

    Hope you can help me out on this, many thanks in advance!

  20. Hello,
    I need to know how to extract everything to the left of a string in a list where there is not the same number of characters on the left side or right side of the string in a column. For example, I need to extract everything to the left of " - Garage 1" and " - Store 2" and " - Building" So, I want to get: Supplies-Other, Repairs-Equip, Salaries-Staff. I'm sure this is pretty simple, but I can't figure it out. Thanks in advance for any help anyone can provide!

    Supplies-Other - Garage 1
    Repairs-Equip - Store 2
    Salaries-Staff - Building 3

  21. Hi there:
    I am struggling to understand something here. I have the following string "avro_67563908_289(000).csv" to which I apply the following formula: `=MID(A6;SEARCH("_";A6)+1;SEARCH("_";A6;SEARCH("(";A6)+1)-SEARCH("_";A6)-1), which results in a `#VALUE!` error. I have spent quite a bit of time trying to understand this, given that the following test formula works: `=MID(A6;SEARCH("_";A6)+1;SEARCH("(";A6)-SEARCH("_";A6)-1)` - it just starts from the first `_` and not the second which is what I want.
    Is there anything obvious that I am doing wrong... the field format is `General`.

    Thanks.
    -M

  22. Hello all, really need your help guys!

    I have a series of columns, for example: Colummn with 3 digit numbers like 420, a column with a word and a number like "Nascar 2", and a column with just a word that says "Honda". I need to make a formula that would combine those 3 columns, but shorten them. So I would use the first number "420", the number from "Nascar 2" and the first letter from "Honda". The solution would be 420-2-H and I need to make a formula for that with the "-" sign in between. Help please!

    1. Hey there:
      I would contemplate a formula using a number of different methods:

      Step 1 is simple and that would just be: =(A1) (for example)
      The second step requires extracting a number from the string and a good reference to achieve this can be found here: https://www.ablebits.com/office-addins-blog/excel-extract-number-from-string/
      The third and final step is simple: RIGHT(C1;1) (RIGHT(Cell-Ref;No's chars)

      Now that you have your formula sorted out, stitch them together using concatenate:
      =Step-1&"-"&Step-2&"-"&Step-3
      Replacing Step-1 through Step-3 with your formula. The = sign is used once at the beginning of the formula.

      Cheers... -M

  23. I want to extract 200 from "200 Euro", "Euro 200", "Euro-200", "200 Euro - 500 Euro",
    all are in a column.

  24. Everything I read from Svetlana Cheusheva is always clear, straight forward and fill with examples. Damn I wish I knew more about MS Excel like her :o)

    Thank you for your excellent postings

  25. Hello!
    Could you please help me to create a formula to obtain the information of the second and the third bracket:

    [Ignacio] Status changed from [one] to [Tweleve]
    [Carlos] Status changed from [hundred] to [five]

    Thanks for you help!

  26. Dear
    Thanks For your Gide to separate W1 from {W1_21} that is sheet name of EXCEL generate from command of {MID(CELL("filename",A29),FIND("]",CELL("filename",A29))+1,255}

  27. how can we pull numbers from any alphanumeric string using a formula.
    Example-
    asd123sd
    123bhs23sd
    sde234jh213

  28. Hi!
    I need to extract following words in my cells, which dont have any specific character and at the same time the amount of 1st words are not same:
    LOOMBNB
    BNBUSDT
    I should separate BNB from a 1st line and USDT from the 2nd one. as you see, I cannot use Text-To-Columns as well.
    please help!
    Thanks

  29. Hello! I have the below and depending on the length of my I need to pull everything up until the second hyphen so:
    PRO85-2700-270S would become PRO85-2700
    SPRI87-4000-400S would become SPRI87-4000

    but then I have some strings with 3 hyphens and I only need to pull up to the 3 characters after the 2nd hyphen.
    Example:
    SLAE01-7000-330-7009-11 would become SLAE01-7000-330

    I have a file with 7K+ rows so any helps would be AMAZING and greatly appreciated!!

    Thanks!
    Nancy

  30. I am using the formula: =SUMIF(Laurie!$A:A,B2,Laurie!$E:$E) to try and get names of people from a separate worksheet tab (tab is named Laurie). But the cells in column E on the Laurie tab are not numbers but someones name. So basically if I put a number in column E cells on the Laurie tab it will show up correctly in my current worksheet tab.
    But any names or non-numbers in the column E cells show up as 0 in my main worksheet. I am guessing this is because I am using the SUM function so it is trying to sum up any number in each cell in column E.
    Anyone help for which function would be best to get the name (or words) form those cells in that column would be great.
    Thanks.

  31. The text string is "47 Nelson Street Kettering Northamptonshire NN16 8QN" in Cell A2.
    Here I need the street(47 Nelson Street), Town(Kettering), county(Northamptonshire) and Code(NN16 8QN) in each separate cell of a row.
    How to do this? Give me the formula for each retrieval.
    Also, another string is "Ref. No: 19/00443/EPHMO Status: Current Licence Applicant Name: Mr Jack Oliver McLoughlin" in cell A3.
    I need only the ref no (19/00443/EPHMO) and the name (Mr Jack Oliver McLoughlin) in separate cells.
    Help me with these formulas.

  32. Sir/madam,
    If a cell contains variable numbers (0 to 6) if cell value is 1 instead of 1 it should display Sunday and so on. Please give me the solution in Microsoft excel.
    Thanks.

  33. I need to extract the first 3 numbers, between the 2nd and 3rd dash. The number of characters between the dash can vary between 3 and 4.
    I purchased the suite and have also used the above formulas and can’t get it to work. It always extracts the complete string between the “-“. I must have it extract only the 1st 3 characters between the dashes.

  34. Hi I'm Rahul Actually I'm new Learner Excel Can You Help Me in Excel

  35. I am trying to extract all letter characters (to the right) following the numbers in the middle of each text line. For example, the first line, I would only need "BLUE CROSS BLU"

    ACH DEPOSIT BCBS INC 462275727 101000011824415 BLUE CROSS BLU
    ACH DEPOSIT HCCLAIMPMT 1932440070 031100200512323 AETNA A04
    ACH DEPOSIT HCCLAIMPMT 1932440070 031100204517462 WPS

    Any ideas on how I could do this?
    Thanks!

  36. i need help to identify in single cell with colour as we have three different things
    5 Pkt -Tata Rallis Fungicide Captaf (Size=500 gm)- 309 -
    1 Unit PGR Induce G 500 ml Rs. 515
    1 Unit Humic Acid Roota 1 kg Rs. 850"

  37. i want to extract name NEW SAHARA BEEJ BHANDAR-TIJARA from NEW SAHARA BEEJ BHANDAR-TIJARA-F C ABS (if sentence containing ABS) with the help of if condition.

    1. Vishal,

      Assuming your data is in A1, the following formula will help:
      =LEFT(A1,FIND("-",A1,FIND("-",A1)+1)-1)

      1. Thanks.formula works.And i have one more problem.If two cell of consecutive rows contain names.One cell having e.g name NEW RAJ BEEJ BHANDAR-NASIK-F C ABS & other cell having name NEW RAJ BEEJ BHANDAR-NASIK.Here i want to extract name NEW RAJ BEEJ BHANDAR from first cell if it contain ABS and otherwise it will remains the same if it doesn't contain ABS

          1. My problem is suppose if two consecutive rows contain names e.g 1st cell does contain name NEW RAJ BEEJ BHANDAR-NASIK-F C ABS and in 2 nd cell doescontain name NEW RAJ BEEJ BHANDAR-NASIK.Now i want to extract only the name NEW RAJ BEEJ BHANDAR-NASIK from name NEW RAJ BEEJ BHANDAR-NASIK-F C ABS (when cell contains ABS). Otherwise the name must remains the same as NEW RAJ BEEJ BHANDAR-NASIK (when it doesn't contain ABS)

  38. I am trying extract only the GB information from a cell in Excel. However in my report, there is an unknown number of times that the GB information will appear and I have at least 2000 lines to go through.

    A cell could look like this:
    0 GB (0% or 1.0:1), 9 GB (31% or 1.5:1)
    or like this:
    453 GB (29% or 1.4:1), 728.25 GB (33% or 1.5:1), 422.25 GB (33% or 1.5:1), 923.5 GB (42% or 1.7:1), 705.5 GB (33% or 1.5:1)

    I want to extract each occurrence of the GB amount (i.e. 0 GB, 9 GB from the first example above and 453 GB, 728.25 GB, 422.25 GB, 923.5 GB, 705.25 GB from the 2nd example above)

    The ultimate goal is to be able to add the GB amounts together for each cell and get a total. I tried splitting the text, but because some of the cells have so many occurrences of GB's it didn't seem like a good choice.

    Does anyone have any ideas?
    Thank you in advance,
    Joanne

  39. Hello i'm trying to extract dimension from an item name column

    E.g. item names are all in a column and one would be "White fence post 80x80 1.8M" but another might be "RT1 35x150 treated decking 4.8MT"

    In these cases how do i pull out just those numbers?

  40. I want to extract last 2 word before and after "-" in one formula
    eg.
    Abc-ccc-ddd, here I need ccc-ddd

    Fff-hhh-kkk-yyy, here I need kkk-yyy

    Kkkk-hhh, here I need kkkk-hhh

  41. If I have this string:

    Babababa{njnj}v_ANDREWGORT@andrew@gort.com

    How do I extract the 'ANDREW' alone?

    This is what I have:

    =MID(C2,SEARCH("v_",C2)+2,SEARCH("GORT",C2, SEARCH("v_",C2)+2) - SEARCH("GORT",C2)-1)

    It appears that "GORT" doesn't work. Is there any way to do this?

  42. I have a data format like this "QA_CASE_1234_John_Smith" How do I extract John Smith in a separate cell without any underscore in John Smith name.

  43. Hi,

    Need some help with extracting data from cell with multiple lines. For example below data is in a single cell. This is a report generated against multiple software with found version and existing version. There are thousands of cell with similar data with "Found: xxxxx". I would like to know a way to get ONLY "Found: xxxxx" data into another column. Would that be possible?

    --------------------------------
    Tested: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

    Found: 4.7.3130.0

    Context:

    Fix: Install the appropriate patch from Microsoft or through Windows Update.
    --------------------------------

  44. i have a string in one cell with length of 400 characters ( A1) . Is there a way i can extract first 150 characters in ( B1) one cell, next 150 in (C1)2nd cell and balance in 3rd (D1)

    Thanks

    Sumesh

    1. Sumesh:
      The answer to your question is easy. My only question is why are there 400 characters in one cell?

      In B1 =LEFT(A1,150)
      In C1 =MID(A1,151,150)
      in D1 =RIGHT(A1,100)

  45. Many thanks! The last name extract worked beautifully -- I'll try the first name next.

    Doug also sent me information -- I really appreciate everyone's help.

  46. I get reports where the name format isn't consistent -- some are FirstName LastName and others are LastName, FirstName.

    Can I use an IF statement combined with your extract formulas to create a single formula that extracts LastName from either format?

    Like this: IF(entry contains comma, LEFT formula, RIGHT formula)

    Would that work?

    And thanks for the great examples and explanations!

    1. Hi Naomi,

      This idea has never occurred to me, but I suppose yes, it will work.

      Here's the formula to extract the last name:
      =IF(ISNUMBER(SEARCH(",",A1)), LEFT(A1, SEARCH(",", A1)-1), RIGHT(A1,LEN(A1)-SEARCH(" ",A1,1)))

      If you'd like to get the first name too, you can find the appropriate LEFT and RIGHT formulas in this tutorial: How to split names in Excel.

      1. I have this same problem. How would you handle the following variation
        John Doe, Jr.
        VS.
        Doe, Jr., John

  47. Hi, how do I remove a decimal point for a number 04.80 to be converted to 0480?
    Thanks for your help.

    1. Hi Emmylou,
      How are you doing, i think you can use substitute function as =SUBSTITUTE(YourCell,".","".
      Thank you.

  48. Abdul:
    If the data is in H37 as one long string, enter this in an empty cell.
    =MID(H37,SEARCH("CHQ",H37)+4,8)
    It says, in H37 find the first "CHQ" go forward 4 characters which includes the "CHQ" and a space and return the next 8 characters.

  49. how can i seperate out cheque no in a seperate cell plz quide me. the data in cel is:
    Cell data
    Cash Withdrawal # 58989,CHQ
    00060706,AHSAN JADOON
    4240113035499 CHQ 00060706 DHA SHAHBAZ BRANCH,4240113035499

  50. Hi,
    I have a sheet with a list of docs (>500k), with their respective path. I want to extract the folder name from the path. Since, it has folders and sub-folders, the folder name doesnt come at the same position. The path is reported as "E:\abc\defg\...\xyz\". Basically, I'm looking to extract the text between the last two "\" i.e. "xyz".
    Thanks in advance

    1. Sid:
      Is it always the case that the information you want is in between the last two forward slashes?

      1. I have the same question - yes the information I need is always between the last two “\”
        Can you suggest me a formula for this

        1. Hello!
          If I understand your task correctly, the following formula should work for you:

          =MID(A1,SEARCH("@",SUBSTITUTE(A1,"\","@",LEN(A1) - LEN(SUBSTITUTE(A1,"\",""))-1),1)+1, LEN(A1)-SEARCH("@",SUBSTITUTE(A1,"\","@", LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))-1),1)-1)

          I hope my advice will help you solve your task.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)