Comments on: Excel MID function to extract text from the middle of a string

MID is one of the Text functions that Microsoft Excel provides for manipulating text strings. At the most basic level, it is used to extract a substring from the middle of the text string. The tutorial explains the specificities of the Excel MID function and shows a few creative uses to accomplish challenging tasks. Continue reading

Comments page 4. Total comments: 303

  1. I have on A1 and A2: In B1 and B2 I write: Resoult:
    A1: HK$11.720 +A2*3 #VALUE!
    A1: HK$0.127 +A2*3 #VALUE!

    If I use:
    For A1 (HK$11.720) =(RIGHT(A2;LEN(A2)-FIND("$";A2)))/1000 11,720 (as normal number) or: =(RIGHT(A2;LEN(A2)-FIND("H";A2)-FIND("K";A2)))/1000 11,720 (as normal number)

    but if use the same formula for A2

    For A2 (HK$0.127) =(RIGHT(A2;LEN(A2)-FIND("$";A2)))/1000 #VALUE! or: =(RIGHT(A2;LEN(A2)-FIND("H";A2)-FIND("K";A2)))/1000 #VALUE!

    If I use (to add –FIND(“$”;A2):

    On A2 (HK$0.12) =(RIGHT(A2;LEN(A2)-FIND(“H”;A2)-FIND("K";A2)-FIND("$";A2)))/1000 0,027 (as normal number but, missing the “1”)

    If I use:

    On A2 (HK$0.12) =(RIGHT(A2;LEN(A2)-FIND("K";A2)-FIND("$";A2)))/1000 0,127 (as normal number)

    Which formula can be use for the two quantities in one time?

    Thanks

    1. Sorry and thanks for your help, I try to clarify as:

      I have:
      A1.- HK$11.720 Write in B1.- +A1*3 Resoult: #VALUE!
      A2.- HK$0.127 Write in B2.- +A2*3 Resoult: #VALUE!

      If I use the formula on:
      B1.- =(RIGHT(A2;LEN(A2)-FIND("$";A2)))/1000 《or》
      =(RIGHT(A2;LEN(A2)-FIND("H";A2)-FIND("K";A2)))/1000 Resoult: 11,720 (as normal number can use)

      But (with the same formula for HK$0.127 (decimal)), can not be use!
      B2.- =(RIGHT(A2;LEN(A2)-FIND("$";A2)))/1000 《or》
      =(RIGHT(A2;LEN(A2)-FIND("H";A2)-FIND("K";A2)))/1000 Resoult: #VALUE!

      If I use to add in B2: –FIND(“$”;A2):
      B2.- =(RIGHT(A2;LEN(A2)-FIND(“H”;A2)-FIND("K";A2)-FIND("$";A2)))/1000 Resoult: 0,027 (as normal number but, missing the “1”)
      If I cancel to use in B2: –FIND(“H”;A2) and add -FIND("$";A2)
      B2.- =(RIGHT(A2;LEN(A2)-FIND("K";A2)-FIND("$";A2)))/1000 Resoult: 0,127 (as normal number can use)

      NOTE:
      A1.- HK$11.720 should to be 11,720
      A2.- HK$0.127 should to be 0,127

      Which formula can be to use for the two quantities HK$11.720 to be 11,720 and HK$0.127 to be 0,127 insted 2 formulas, one for natural number and one for decimal number?

      I need to create an excel table with more than 2.500 datas/x column take (page/copy) from a Government HK web for financial companies in HK.

      When I make the page/copy, the HK$(+number) are no numeric and also I don´t know, ” its not as texto”, can not use on formulas, can not change from texto to number.

      I can do/use it if I change/create as normal number without HK$ and with “,” instead “.”, by create a formula as explain above.

      Thanks Alexander

      1. A1.- HK$11.720
        A2.- HK$0.127
        A3.- HK$0.048

        Formula in B1 / B2 / B3: =(RIGHT(A2;LEN(A2)-FIND("$";A2)))/1000 or =(RIGHT(A2;LEN(A2)-FIND("H";A2)-FIND("K";A2)))/1000

        Resoult:
        B1.- 11,720 (as normal number)
        B2.- #VALUE!
        B3.- #VALUE!

        Formula in B1 / B2 / B3: =(RIGHT(A2;LEN(A2)-FIND(“H”;A2)-FIND("K";A2)-FIND("$";A2)))/1000

        Resoult:
        B1.- 0,900 (as normal number but, missing the “11”)
        B2.- 0,027 (as normal number but, missing the “1”)
        B3.- 0,048 (as normal number)

        Formula in B1 / B2 / B3: =(RIGHT(A2;LEN(A2)-FIND("K";A2)-FIND("$";A2)))/1000

        Resoult:
        B1.- #VALUE!
        B2.- 0,127 (as normal number )
        B3.- 0,048 (as normal number)

        1. Hi!
          To extract a number from the end of a text try this formula:

          =--SUBSTITUTE(MID(A2,SEARCH("$",A2)+1,50),".",",")

      2. Hello!
        We have a ready-made solution for your task. I'd recommend you to have a look at our Remove Characters tool.
        It is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and check how it works for free.
        You can replace "." with "," using the standard Find & Replace tool.
        If something is still unclear, please feel free to ask.

  2. Hi, if I have a whole number like 20090206 and I want to format into dd:hh:mmss (20:09:02:06). How would I proceed to include the ":" delimiter spaced by two numbers? Thank you!

    1. Hi!
      With the MID function, take every 2 digits from the number.

      =MID(A1,1,2)&":"&MID(A1,3,2)&":"&MID(A1,5,2)&":"&MID(A1,7,2)

      The formula returns text.
      You can use a custom number format:

      ##":"##":"##":"##

  3. In a single cell I have a cluster of numbers separated by tabs or spaces ; I am trying to isolate just the starts with 79 numbers that are always 13 digits in a separate cell
    Example...
    7981107135154
    110567815X
    1316135086

    I was using formula =TRIM(LEFT(SUBSTITUTE(MID(C5,FIND("7",C5),LEN(C5)),"",REPT("",LEN(C5))),LEN(C5))) but it doesn't put a stopper to the digits so I get everything that follows it.

    Any Ideas how I can isolate it?
    Thanks
    NEMA

    1. Hi!
      Sorry, it's not quite clear what you are trying to achieve. Explain in more detail. Give an example of your cluster of numbers and the desired result.

  4. Thank you for the formula. It works.

  5. Hi,

    I am trying to convert 30-jun-21 01.45.18.488173000 pm to 1:45. Please help someone with mid and substitute function together.

    1. Hello!
      Please try the following formula:

      =TIME(MID(A2,SEARCH(" ",A2,1)+1,2),MID(A2,SEARCH(" ",A2,1)+4,2),0)

      1. Hi,

        I am trying with the formula TIME(MID(A2,SEARCH(“ “,A2,1)+1,2),MID(A2,SEARCH(“ “,A2,1)+4,2),0).

        The timestamp is showing as 12:07:00 PM.
        I am not getting the “ss” number as result.
        It should be 12:07:24.

        Please guide.

        1. Hi. I was applying the formula in a rough data timestamps. When I apply it on real data sheet timestamp. The file is pulled from a sql, it is not capturing the ‘ss’ value.

      2. Hi. The above formula works to convert into normal time format.

        The above timestamp format is 30-jun-21 01.45.18.488173000pm which is 1:45:00.

        I have got four timestamps:
        17:39:38
        17:41:35
        17:45:35
        17:45:00( convention of above mentioned timestamp 1:45:00 +TIME(4,0,0)

        I am trying to get the time difference with consecutive timestamps which I will get 3 time difference.

        Problem: I have applied ABS(timestamp1-timestamp2) to find each difference.

        But when I apply, =MAX(timedifference1,timedifference2, timedifference3)

        I get the time difference of last two timestamps which is of 35 secs as maximum value. And I tried to convert all to text that shows the last timestamp is taking both date and time in calculation.

        And other two difference are 00:01:57 and 00:04:00.

        I should get 00:04:00 as maximum value. Please help me out on this as I am trying with random formulas but no success.

      3. Can I get the time in 1:45 PM? The formula works but it shows 1:45 AM.
        Please advise on how timestamp can be shown in both AM and PM when pulled the respective data in AM and PM.

  6. This is awesome! I am managing an excel sheet of my expenses and I just copy pasted your formula =MID(A2,SEARCH(", ",A2)+1,SEARCH(", ",A2,SEARCH(", ",A2)+1)-SEARCH(", ",A2)-1)

    It was so accurate. Thank you for sharing this! Amazing!

  7. caution, this webeditor corrupts the formulas when posting. I did type a completely different formula than the one stated in my comment above!!!!! don't use it!

  8. the string published above for selecting a string of letters between certain keys in that string is unfortunately wrong. The function MID requires more brackets, and uses semicolon.
    Use this one if you want to select the string between "". E.g. in field A2 you have the string: improfessionalexcel, which will give you the word "using".

    =MID(A2;SEARCH("";A2)-(SEARCH("<";A2)+1)))

    1. Hi!
      The formula is correct and works. The use of semicolons depends on the regional settings of your Windows.

  9. Hello! I hope you guys can help me with my case :)

    %B6009210202107390^SMITH/JOHN I ^4912120000004825853 000 ?;6009210202107390=49121200000000000000?

    If I would want to extract "^4912120000004825853" how should I use this formula?

    Thanks!

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

      =MID(A2,SEARCH(" ^",A2,1)+2, SEARCH(" ",A2,SEARCH(" ^",A2,1)+1) - (SEARCH(" ^",A2,1))-2)

      Hope this is what you need.

  10. I need the get the following characters

    FG-F19951-D02-12 = get the new colomn D02

    1. Hello!
      You can use this formula:

      =MID(A2,11,3)

      If this is not what you wanted, please describe the problem in more detail.

  11. My work consists of string with two occurrences of this sign ":" , i.e. Account Num.:76372/B098:COM and I want to get only 76372/B098 in a single column.

    I found the formula MID(A2,SEARCH(":",A2)+1,SEARCH(":",A2,SEARCH(":",A2)+1)-SEARCH(":",A2)-1) is very helpful and exactly solved my problems.

    Thank you so much. You really help my work more easily. :)

  12. hello,
    i hneed a little help
    i have a excel with some documents that have barcodes and i time stamp when are they created and i need to do somehow so that i know how many unfinicheddocuments i have before 14:00.the format of the cell is like this 08.03.2021 14:36:45,it is from excel extracted from e program that we use.i tried this formula : MID(D3;12;2)+IF(H3<14;"overdue";"still in frame") but is not working,separatly they are working but i tried to have just one formula.i think the error is from H3 from IF function.tks

  13. Hello,

    I want to know that how to extract any text from the cell.
    There can be some sentences.

    Thank You...

    1. Hi,
      Have you tried the ways described in this blog post? If they don’t work for you, then please describe your task in detail, I’ll try to suggest a solution.

  14. Hi,

    I have 100s of rows of entries with different time stamps similar to -
    2021-01-25T12:32:56.698+0000

    These time stamps range for a period of up to 30 days, from 8am - 11pm
    I've used LEFT and MID to create 2 new columns with date and time, such as 2021-01-25 & 12:32:56

    So I now have 100s of entries with a nice date - time format

    Now I want to get a total of how many times there's an entry recorded between 08:00-12:00 - 12:-01-16:00 - 16:01-20:00 and 20:01-23:00
    ,
    I can't work out how to do this, as you can't sum the results, as they are output from the LEFT/MID queries.

    Please help thanks :)

    1. Hello!
      Your date and time are recorded as text. Use the DATEVALUE and TIMEVALUE functions to convert them.
      Here is the article that may be helpful to you: Using Excel COUNTIF function with dates.
      To calculate the time, you can use something like this formula

      =COUNTIF(B1:B4,">"&TIME(19,0,0))

      I hope I answered your question. If something is still unclear, please feel free to ask.

  15. Hi,
    So I have thousands of SKU numbers with design, width, and length code included. I want to break the code down as I wish. I can use the MID function but not all the codes have the same character number or sequence.
    Some examples of the SKUs:
    0101_27in02ft
    CUS-1980-32in07ft
    STD8702-8X10

    As you can see above first design code comes, then width and length.
    How can I break down approx. 12000 items in my list?
    Your help will be greatly appreciated.

    Happy new year,
    Tim

  16. IMPS/P2A/036310898577/9485/8812103889

    can anyone help me find 036310898577 this one

  17. Choice hotel | US performance report | WC 18 Dec | 24 Dec | 1700 est

    How i can split this by using formula in excel,
    As required choice hotel in different column, US performance report in different column, and 24 Dec and 1700 est in different column.

  18. Hi,

    How do I extract the LAST word from the cell that contains any of the specific characters?

    Example:
    1. FirstName LastName 7.8 2
    2. FirstName LastName 7.9 2
    3. FirstName LastName 8.1 7.5 3
    4. FirstName LastName 1:04.84
    5. FirstName LastName 1:15.84 1:07.84

    Should return:
    7.8
    7.9
    7.5
    1:04.84
    1:07.84

    Thanks!

  19. Awsome work Alexander. Works perfectly!

  20. Hello

    I use the following formula =-LOOKUP(1,-LEFT(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),LEN(A1)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))+1),ROW(INDIRECT("1:"&LEN(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),LEN(A1)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))+1))))))

    This gives me the first set of digits (202009260630) in the string below, however I need to change this around so it gives me the last set of digits between underscore and .zip, in this case (1). I hope its just some minor adjustments to the provided formula that is needed.

    If anyone is thinking of more smooth solutions I can add that the amount of underscores varies, and that the amount of digits between last underscore and.zip also varies. IE string length varies

    Ramen_files_202009260630_1.zip

    1. Hello!
      Please describe your problem in more detail. Include an example of the source data and the result you want to get. It’ll help me understand your request better and find a solution for you.

      1. So Sourcedata look like this;
        gateway_files_202009250630_21.zip
        Big_files_202009300630_2.zip
        Glimmering_dust_stars_202010010630_5621.zip

        The formula i provided in the first post provides me with the following set of digits from each row;
        202009250630
        202009300630
        202010010630

        Now, what I wan't it to do is to provide me with the last set of digits in each string;
        21
        2
        5621

        Let me know if you need me to elaborate further :)

          1. Hello Alexander,

            I will elaborate further. Regarding the link you sent me, none of the examples include a string with 2 different set of digits(numbers in them). I'm not interested in extracting all numbers. I am interested in extracting the last set of numbers that in this case is between the last _ and .zip

            The link also mentions using positions, but position varies as the filename lenght varies.

            The reason why I provided this formula: =-LOOKUP(1,-LEFT(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),LEN(A1)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))+1),ROW(INDIRECT("1:"&LEN(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),LEN(A1)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))+1))))))

            Is because the way I understand it is that it searches from the left til it hits the first digit(number) and continues until it hits a non number Thus providing me with the whole numberseriers of only the first continous numberseries.

            I'm no expert in this but I thought maybe one of the experts here knew how the formula i provided could be tweaked to do exactly the same, but start from the right, so I get the last continuous numberseries of the source data.

            In other words I want the formula to return 21 from the following source data; gateway_files_202009250630_21.zip

            1. Hello!
              Here is the formula that should work perfectly for you:

              =MID(SUBSTITUTE(A2,"_","@",LEN(A2)-LEN(SUBSTITUTE(A2,"_",""))), FIND("@",SUBSTITUTE(A2,"_","@",LEN(A2)-LEN(SUBSTITUTE(A2,"_",""))))+1, SEARCH(".",C8,1)-SEARCH("@*.",C8,1)-1)

              Hope this is what you need.

              1. Hello Alexander,

                Sorry for a late reply,
                Im not an expert in this, but it seems like you refer to something in cell C8, It's not obvious to me what this is. I assume the filename is located in A2.

                Are you able to provide a picture of the extracted result from the file with the sourcedata where the formula is applied? :)

              2. Hello,
                I am sorry for the inaccuracy. Here is the complete formula

                =MID(SUBSTITUTE(A2,"_","@",LEN(A2)-LEN(SUBSTITUTE(A2,"_",""))), FIND("@",SUBSTITUTE(A2,"_","@",LEN(A2)-LEN(SUBSTITUTE(A2,"_",""))))+1, SEARCH(".",SUBSTITUTE(A2,"_","@",LEN(A2)-LEN(SUBSTITUTE(A2,"_",""))),1) -SEARCH("@*.",SUBSTITUTE(A2,"_","@",LEN(A2)- LEN(SUBSTITUTE(A2,"_",""))),1)-1)

  21. I have an excel with transaction downloads from my bank. One column has the entries for the vendor of teh transaction but all are long and can differ. I want to extract one word (the vendor name) and place it in the next column in that row.

    So, let's say that the cell D48 has a long string such as:
    "DEBIT PURCHASE RET - VISA AMAZON.COM AMZN.AMZN.COM/BILWA".
    I want to find one word AMAZON and place that in cell E48.

    I will use the formula you provide to do this function for all my vendors, like PGE, AT&T, "Fred Meyer"

    1. Hello!
      The information presented to you is not enough to give you advice.
      What pattern do you want to search for a supplier's name?
      Give some examples of the source data and the expected result.
      It’ll help me understand it better and find a solution for you.

  22. Hi
    I would need some help on following extraction:
    I need to extract the sender person of a bank transaction. So, I need to extract the words between the IBAN (which always starts with CH* and always has 21 digits) and between the word SENDER. IBAN is variable and count of extracted words as well (2,3 or 4 depending on sender reference name).
    Example of my cell:
    GIRO BANK CH9909990456345323499 Tester Max Noah Bern SENDER REFERENCE
    Extraction should be "Tester Max Noah Bern"
    Thanks a lot!

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

      =MID(E1,FIND("CH",E1,1)+22,FIND("SENDER",E1,1)-(FIND("CH",E1,1)+22))

      We have a tool that can solve your task in a couple of clicks: Ablebits Data - Split Text.

      This tool is available as a part of our Ultimate Suite for Excel that you can install in a trial mode and use for free: https://www.ablebits.com/files/get.php?addin=xl-suite&f=free-trial

      1. Thanks for your quick answer!
        Unfortunately this does not work, because we have 2 problems:
        - leading words can be different in count and variation (can have 4,6,7.. words)
        - and leading words can include "CH" as well
        e.g. another row looks like this:
        GIRO BANK RAIFFEISEN SCHWEIZ GENOSSENSCHAFT DORFSTRASSE 99 999999 ALIGDNSLIW CH9812349000003109099 Beatrice Tester Bernstrasse 99 1234 Bern SENDER
        From here I would have to extract "Selina"" ""Howald"" "Bern".
        So I always have to extract the 2 words after the IBAN (right from CH*) and 1 word left from "SENDER". Count of words at beginning can differ as written above.
        Thanks again for your help!

          1. Hi
            Thanks, I tried your tool (Mac version) and it would work as workaround.
            But still I would be looking more in a formula, because this formula will be part of a longer formula in which I consider different types of extractions.
            So, how would I split text with mask by formula? Or how would I create the formula for my need described above?
            Thanks again for your help!

  23. I have a problem like this, the more number of letters I will separate, for example G: \ DCC \ EPC \ PIPELINE \ MRPR \ FINAL DOCUMENTATION
    I want to separate 1 (G), 2 (DCC), 3 (EPC), 4 (PIPELINE), 5 (MRPR), 6 (FINAL DOCUMENTATION) please find a solution, Thank you very much

    1. G:\DCC\EPC\PIPELINE\MRPR\FINAL DOCUMENTATION
      G, I Use Formula =MID(A2,1,SEARCH(":\",A2)-1)
      DCC, I Use Formula =MID(A2,SEARCH("\",A2)+1,SEARCH("\",A2,SEARCH("\",A2)+1)-SEARCH("\",A2)-1)
      EPC, I don't know yet, solution please
      PIPELINE, I don't know yet, solution please
      MRPR, I don't know yet, solution please
      FINAL DOCUMENTATION, I don't know yet, solution please
      Thanks You Very Much

        1. Thank you, I understand what you mean, it's easier to use the excel data facility "Data -> Text to Columns -> chose delimited -> next -> others -> \ -> next -> finish" but I ask for a solution with the formula if possible, Thank you very much
          Hairul Alam

      1. but if possible I need a formula for my problem, Thanks

  24. How to search three values using mid function i.e. use of "OR" statement in mid formula so we can able to search specific value thats meets two criteria (i have a lot of excel rows containing data in which sonme of them have personal information of persons and some of them are containing word "Vacant" so i would try to extract data of all cell and result shown personal data of persons and as well as word "vacant" shown if the cell containing data "Vacant". please help me!!!

  25. I am trying to extract the last characters in a string. However the string is not always the same length nor the number of characters I need to extract, example:
    29374sp
    aw825885hxpc
    ae4528-10xp
    I need the characters at the end of the string after the numbers. Any help would be great.
    Thanks

    1. Hello!
      To get all characters in the text after the last number, you can use the formula

      =RIGHT(A2,LEN(A2)-MAX(IFERROR(IF(SEARCH({1,2,3,4,5,6,7,8,9,0},MID(A2,ROW($1:$99),1))=1,ROW($1:$99)),0)))

      I hope this will help

  26. Hello guys, can someone help with getting the first value on a text.
    So i want to get the 1st numbers on this text:
    ABCDEFG 1234 (ABCD 1920) I want to get the 1234
    BCBAKHJFAKFAHKLJS 1237214 (BABY-HKLJ) I want to get the 1237

    Please need help, thank you.

    1. Hello!
      To extract the first 4 digits from the text, you can use this formula

      =MID(A1,MATCH(0,--ISERROR(-MID(A1,ROW($1:$99),1)),),4)

      Hope this is what you need.

      1. I'm working on a large amount of data. What i want is to determine if the old plan versus the new plan is a "Upgrade", "Downgrade" or "Retain".

        Sample: Old Plan vs New Plan
        Family Plan 1299 vs FamCombo 1699 result "Upgrade"
        ValuePack 599 (Data 299) vs Family Plan 1999 (All in 1299) result "Upgrade"
        So the bases plan is the 1st number. How can i construct the IF statement on this one? Need your help!

        Thank you so much!

        1. Hello Suanson!
          I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail?
          Please explain in more detail what conditions are "Upgrade", "Downgrade" or "Retain"?
          Why "Family Plan 1299 vs FamCombo 1699 result" Upgrade "? Under what condition will the result be "Downgrade" or "Retain"?
          Is this entry in one cell or in several?

          1. It's like this...
            If B is greater than A then it will display "Upgrade"
            If B is less than A then it's a "Downgrade"
            IF B is equal to A then the plan has been retained "Retain"
            (B is the old plan while A is the new plan)

            1. Hello!
              You haven't answered all my questions. I don't want to waste time guessing. I ask again. "Family Plan 1299 vs FamCombo 1699" - written in one cell or in several? Are the numbers 1299 and 1699 being compared? If you want help, please describe in detail your problem.

              1. It's written in different cell.
                Column A Family Plan 1299
                Colum B FamCombo 1699

                and yes, the numbers are being compared. Sorry i have a very limited time in the office, and can only access it here.

      2. It works like charm! Thank you so much Alex!

  27. (Backlash X @ -3.5 @ 4.0mm) If I want extract the value between @ and @ in the next cell @ and mm how to apply the mid and find function...

    1. Hello!
      The formula below will do the trick for you:

      =MID(A1,FIND("@",A1,1)+1,FIND("@",A1,FIND("@",A1,1)+1)-FIND("@",A1,1)-1)

      I hope this will help

  28. How can i extract the first number on these data.

    ThePLAN PLUS 1299 (Value 1899)
    ThePLAN 1799
    ThePLAN PLUS 1299 (Value 1899)

    1. Hello!
      If I got you right, the formula below will help you with your task:

      =--MID(SUBSTITUTE(B2," ",""),MATCH(TRUE,ISNUMBER(--MID(SUBSTITUTE(B2," ",""),ROW($1:$24),4)),0),4)

      I hope this will help

      1. Thank you so much Sir Alexander Trifuntov (Ablebits.com Team), you're awesome!!!

  29. could someone help to get the output only with the date. There are 2 different dates in one column..
    Generate on Begin time :Sun Jul 5 0:0:0 2020
    GenerateOn Begin time : Sun May 10 05:36:52 2020
    I would require the output as MM/DD/YYYY Only from both the fields..
    Thanks in Advance..

    1. Hello!
      If I got you right, the formula below will help you with your task:

      =DATE(RIGHT(A1,4),VLOOKUP(MID(A1,5,3), {"JAN",1;"FEB",2;"MAR",3;"APR",4;"May",5;"JUN",6;"JUL",7;"AUG",8;"SEP",9;"OCT",10;"NOV",11;"DEC",12}, 2,0), MID(A1,FIND("#",SUBSTITUTE(A1," ","#",2))+1, FIND("#",SUBSTITUTE(A1," ","#",3))-FIND("#",SUBSTITUTE(A1," ","#",2))-1))

      Custom date format in the cell set as you need.

      1. Good Morning Alex !
        actually both the mentioned format is different and having text as well.. I have pasted example below. from below 2 columns I need to extract the date in respect to any date format (like dd/mm/yyyy) or (MM/DD/YYYY) but that should be standard.. would appreciated to help me in this regards Sir.. Thanks in Advance..

        Generate on Begin time :Sun Jul 5 0:0:0 2020
        GenerateOn Begin time : Sun May 10 05:36:52 2020

        1. Hello!
          I used both dates from your message in the formula. Got the correct result. I don’t understand what problem you have.

  30. Is there a way to use a mid function if you do not know the location of the number you are looking to pull?
    For example, I am uploading email confirmations for an excel file. I need to pull out the order number from the subject column for each line. However, I do know the numbers I am looking for are 7 digits long and begin with a 9. Is there a way to use a mid function to pull a number if it meets that criteria?

    1. Hello Cate!
      You can extract the account number from the text -
      like text

      =IF(ISNUMBER(--MID(E1,SEARCH("9",E1,1),7)), MID(E1,SEARCH("9",E1,1),7),"")

      or as a number

      =IF(ISNUMBER(--MID(E1,SEARCH("9",E1,1),7)), --MID(E1,SEARCH("9",E1,1),7),"")

  31. Hi,

    I have one excel like this value 0+11+21+32+45+112+37,
    i want to split using formula to like 0,11,21,32,45,112,37 in different cells.
    I found first 2 values,
    =LEFT(A3,SEARCH("+",A3,1)-1) (First number)
    =MID(A3, SEARCH("+",A3) + 1, SEARCH("+",A3,SEARCH("+",A3)+1) - SEARCH("+",A3) - 1) (second number)
    but I am unable to get next number onwards.

    Could you help me

  32. 10001_PRV01
    10001_PI03
    10001_F01
    How can I get the only "PRV";"PI"& "F" by using one formula from the data?

    1. Hello
      Using the MID function to extract only text without numbers

      =SUBSTITUTE((CONCAT(IF(NOT(ISNUMBER( --MID(A1,ROW($1:$93),1))), MID(A1,ROW($1:$93),1),"")))," ","")

      I hope it’ll be helpful.

  33. Hi, Fantastic Article!
    I love this formula.
    =TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),MAX(1,FIND("$",SUBSTITUTE(A2," ",REPT(" ",99)))-50),99))
    I got a question, how to change to formula if we want to extract more than 2 $ in A2
    Thanks in advance.
    Brilliant Formula.

    1. Hello!
      If I understand your task correctly, you would like to extract the second number from the text that starts with the $ sign. If so,
      from text
      "This item costs $50 and you get a discount of $15"
      we extract "$15".

      =TRIM(MID(SUBSTITUTE(REPLACE(A2,FIND("$",A2,1),1,"")," ",REPT(" ",99)), MAX(1,FIND("$",SUBSTITUTE(REPLACE(A2,FIND("$",A2,1),1,"")," ",REPT(" ",99)))-50),99))

      Hope this is what you need.

      1. What if we want to extract up to 5 set of number in a text? For example $50, &23, $45, $56 and %60.

      2. Thanks for your quick reply. Brilliant!!
        "This item costs $50 and you get a discount of $15"
        Actually, I would like to extract the $50 and $15, both of them. And also if possible to extract the word of $ 15 (there is space between the $ and 15 or any word ($ xx) (xx=number))

        Thanks in advance.

        1. To get both numbers in one cell, you can combine the results of the first and second formulas using the & operator.
          Something like
          =C1 & " " & C2
          I hope this will help

  34. Je voudrai un algorithme avec la fonction mid qui peut calculer le nombre de mots d'un document entier s'il vous plaît

  35. Hi
    Thank you in advance for helping me with formula.
    I need to get the middle section of the id number and if the number is smaller than 4999 it should show F for Female if it is bigger than 5000 it should show M for Male. I am using the following formula but I am doing something wrong. The ID number is 5711261588092 and the middle part is 1588 so it should return F.
    =IF(MID(F2,7,4)<=4999,"V","M")

    1. Hello Reinette!
      The formula below will do the trick for you:

      =IF(--(MID(F2,7,4))<=4999,"F","M")

      The MID function returns the text that you are comparing with a number. Therefore, you get the wrong result. I have converted your text to a number.
      I hope this will help, otherwise please do not hesitate to contact me anytime.

  36. Hello Vince!
    For me to be able to help you better, please describe your task in more detail. It’ll help me understand it better and find a solution for you. Thank you.

  37. I have data set with US and Canadian addresses in one column. I tried using the text to columns functions in order to break everything, but it's inconsistent. Is there any way of using these formulas to pull out the US states and Canadian territories?

  38. this function =REPT("0",4-LEN(A1))&A1 use for Len sent
    Result
    1
    0001
    But how to use for 1 to extend 1000.

    1. Hello Vivek!
      If you want to add 0 at the end of the value in cell A1, please use this formula:
      =A1 & REPT("0",4-LEN(A1))
      If you want to increase the length of a string, please change number “4” in the formula to the necessary number, e.g. 5,6,7, etc.
      If you mean something different, then please describe your problem in more detail.

  39. Apple iPhone 6 Space Grey 16 GB RAM ROM
    Model Name
    Model
    Ram
    Rom
    Alag kesa kr sakte h

  40. I am using the MID function to concatenate three columns. Similar to this formula
    =MID(A1,6,1)&MID(A1,8,1)&MID(A1,9,6).
    The formula works, but there is a space between the concatenations. How do i remove these spaces?

    1. Hello,
      Hello Gregg!
      The formula below would help you get rid of the spaces in your text:
      =SUBSTITUTE(A2," ","")

      There is also a ready-made solution for your task called Remove Characters tool that will delete the necessary characer in tyour range in a click. Check out the tool's manual here

  41. Hi.
    I have a rather complex formula and one portion of it is not working. Basically, one cell (C17) Has wording that shows how many boxes in a bundle there is. However, this item has 2 parts to the box. The cell says "375 TOP450 BOTTOM" which represents that the top portion of the box comes 375 in a bundle and the bottom portion comes 450 in a bundle. It uses the Char(10) function to place it in 2 lines within the same box. In another box (B17) is the amount of cases that are needed for a run. What I need to return in a separate box is a calculation of how many bundles are needed for the top and bottom rounded up to the nearest number. Essentially, if we need 1875 cases total it should return "5 TOP 5 BOTTOM". The first half of the formula works fine. The second half is not recognizing the extracted number as a number which is making it return a VALUE# error. I tried to wrap the function as a number but that still down't work.
    Here is the part of the formula that works and returns 450 as expected:
    =MID(C17,SEARCH("P",C17)+2,ABS((SEARCH("P",C17,SEARCH("P",C17)-1)-SEARCH("B",C17)+2)))
    It is when I try to divide the total cases needed by that number extracted extracted that I get the error.
    1875/(MID(C17,SEARCH("P",C17)+2,ABS((SEARCH("P",C17,SEARCH("P",C17)-1)-SEARCH("B",C17)+2)))) should return 4.16
    If I add the Value function like below, I get a value error.
    1875/value(MID(C17,SEARCH("P",C17)+2,ABS((SEARCH("P",C17,SEARCH("P",C17)-1)-SEARCH("B",C17)+2))))
    How can I get the mid function depicted to recognize the return as a number?

    To be clear, the first portion of my formula worked. So I was able to extract the 375 and divide 1875 by 375 and return the expected value as 5. It's only this second half I am having trouble with. Can anyone please help?

  42. =IF(MID(J2,2,1)="O","OO","RT") --- i have this formula correctly.

    However, i need to add another criteria MID(J2,3,1)="O"
    Please help.

    Thank you!

  43. Great article!
    I'm trying to do a complex string and struggling to get the final output:
    Original=C:\zeddn\AI01653_-W_DER8ZZ13.pdf
    Formula Output= \AI01653_-W (close - but I don't want the \ in the result.
    '=MID(A30,SEARCH("\",A30,SEARCH("\",A30)+1),SEARCH("_",A30,SEARCH("_",A30)+1)-SEARCH("\",A30,SEARCH("\",A30)+1))

    Using your example with a -1 at the end, doesn't work either:
    Original=C:\zeddn\AI01653_-W_DER8ZZ13.pdf
    Formula Output= \AI01653_-W_DER8Z (not close, do not want anything from the second underscore on in the result.
    '=MID(A30,SEARCH("\",A30,SEARCH("\",A30)+1),SEARCH("_",A30,SEARCH("_",A30)+1)-SEARCH("\",A30,SEARCH("\",A30)-1))

  44. Hi I have a query, i have to search multiple 8-10 Character strings from one cell example A1 like SAM1, SAM2, SAM3, SAM4, ZOP1, ZOP2, ADS1, ADS2.... and need to update the matching value example B2 SAM12345. Kindly advise me how could this be achieved. I have used the below formula but it has not worked, kindly provide your assistance....
    IF(ISNUMBER(SEARCH({"SAM0","SAM1","SAM2","SAM3","SAM4","SAM5","SAM6","SAM7","SAM8","SAM9"},$A1,8))=TRUE,MID($A1,SEARCH({"SAM0","SAM1","SAM2","SAM3","SAM4","SAM5","SAM6","SAM7","SAM8","SAM9"},$A1)+9,7)

  45. Hi,
    i want to "HSBC - Any domestic business banking relationships - Please now think about your personal banking relationships and the business' domestic banking relationships in Australia" this text as "Please now think about your personal banking relationships and the business' domestic banking relationships in Australia - Any domestic business banking relationships - HSBC", please help me how i can do this.

  46. Hi!
    I am using the following to extract "ES" text from a cell. How can I edit the formula to extract additional text, i.e. "ES", "MS", and "HS"? Thanks a lot in advance!
    =TRIM(MID(SUBSTITUTE(F19," ",REPT(" ",99)),MAX(1,FIND("ES",SUBSTITUTE(F19," ",REPT(" ",99)))-50),99))

  47. Can i make mid function start from the right direction and select the number on the left side of the spesfic number with out use right function ?

  48. HI, I used this formula =TRIM(MID(SUBSTITUTE(E4991," ",REPT(" ",99)),MAX(1,FIND("IL",SUBSTITUTE(E4991," ",REPT(" ",99)))-50),99)), which worked well with my case 2 and 3 below but did not give the desired result for case 1 and 4 due to the fact that there are no space in the case 1.
    Result i need is 16 characters starting with IL included.
    Case 1 : MF20020011111IL11000NG0000001
    case 2 : MF20020022222 IL11000NG0000002 revalued
    case 3 : IL11000NG0000002 MF20020022222 revalued
    Case 4 : MF20020033333IL11000NG0000003revalued
    Thanks

  49. trying to get it to use an IF function along with a MID in extracting numbers withing a string of both text and numbers.

    PBQ4X5 - using =MID(A2, SEARCH("Q",A2)+1, 1) to return the "4" and the same with "X" to return the number associated with it. Unfortunately when it runs across a sequence that doesn't include either the X or the Q (PBI5G3), I get "#VALUE!". I also get "#VALUE when trying to "sum" the number columns that the formula returns. Trying to come up with an IF formula to incorporate with the MID and SEARCH so that it will return a "0" when it can't find the particular text (Q or X). Any help would be appreciated, I've been working on this for quite a while.

  50. Hi, Fantastic Article!
    Is there any way to search for additional data within the same cell and have all the data that is pulled out, separated by a comma?
    I have a cell with 1 to 5 user names and ID's. The ID's are in parenthesis and I want to pull the ID's out to be separated by a comma.
    My worksheet is setup like the data below in a single column, but with 240 rows.
    Smith,Jim A (123456)Doe,John (789123)
    Doe,Jane(393027)
    Boss,Tim (293029)Deer,Fred(001289)Stern,Greg(148900)
    I'm trying to get the data to return like this:
    123456,789123
    393027
    293029,001289,148900

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 :)