+ Reply to Thread
Results 1 to 24 of 24

Formula for text extraction

  1. #1
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Formula for text extraction

    I have the following formula in a cell in order to extract a specific value from a text box. =MID($A2,FIND($F$1,$A2)+LEN($F$1)+2,20)
    The issue is that 20 characters at the end runs into a diferent section which I don't want here. I need to keep it 20 because that is how long the text string I need is. I want this fomula to be universal for all of my text cells.
    How can I add to this fomula, keeping the 20 character length, but making it stop giving values once it reaches the next word in the text box?

    See details in attachement
    Attached Files Attached Files
    Last edited by viber52; 07-07-2015 at 12:58 PM. Reason: Rules

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Finish the formula....

    Title OK. Post removed
    Last edited by Pepe Le Mokko; 07-08-2015 at 03:36 AM.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Finish the formula....

    While you are changing your title, please post an Excel sheet, too. Without seeing some representative examples, this involves way too much guesswork.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Finish the formula....

    The changes were made. Please act accordingly.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    So sounds like you only want complete words so if 20 characters would cut a word in half, you'd want less than 20 characters.

    With your string in A1, try
    =TRIM(LEFT(SUBSTITUTE(A1," ",REPT(" ",20)),(20-LEN(SUBSTITUTE(LEFT(A1,21)," ",""))+1)*20))
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    ChemistB, I would still need it to be an extention of my formula because it needs to look for the words "confirmation number" (B1). That's how it finds the correct value to find.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    I see

    Try this
    =TRIM(MID(SUBSTITUTE(A2,CHAR(10),REPT(" ",20)),FIND($D$1,SUBSTITUTE(A2, CHAR(10), REPT(" ",20)))+21,20))

  8. #8
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    ChemistB, The formula isn't returning what's needed. I attached the spreadsheet I'm working on. I need to sort the leftmost text boxes into the proper categories by only extracting the text string needed. The cells highlighted in green are the problems that I have.

    The function we discussed earlier is in cells M3, M4, N3, N4.

    I appreciate your help.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    Yeah, you have so much going on here, I'm not sure you can catch everything.

    "General Job Completion Notes" occurs twice in each cell in A and has an immediate line break after it. So I fixed that in Column A.
    I modified the formula So it's always looking at the proper header and calculating an offset based on the length of that header.

    This probably would require VBA to fix everything. Perhaps you should post in the Excel Programming folder.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    Your sheet looks much better for all the smaller fields. However, the job notes field is most important to me. Any other ways I can extract that data better? It's difficult because what I'm given is inconsistent.
    The comment boxes are enetered in the computer this way by others. So I have to make them show the fields properly as they are.
    Also, why are some of your fields blank? You used a "Iferror" wrapper so It should give "N/A" right?
    Last edited by viber52; 07-07-2015 at 05:01 PM.

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    Do you want the job notes to be longer than 20 characters?

    I don't see any fields that came back blank.

  12. #12
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    The fields in green (N4, M4, D3). Yes I would like the entire job notes description in the "general job completion notes" cell. I would like it to stop prior to the next subject/category. Is there a way to make the formula see where that text string ends?
    Last edited by viber52; 07-07-2015 at 05:43 PM.

  13. #13
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    Okay, for the General Job Completion Notes, in D2 put

    =TRIM(MID(A2, SEARCH($D$1&":",A2)+LEN($D$1)+2, SEARCH(CHAR(10)&CHAR(10),A2)-(SEARCH($D$1&":",A2)+LEN($D$1)))) copied down
    This assumes that after the Job Notes, there is a double line break (CHAR(10)&CHAR(10)) which is not true for your last entry in Col A of your example. You'd need to manually enter a line break before "Paperwork Completed by:

    For the other columns
    In E2 copied down and to appropriate columns
    =IFERROR(TRIM(MID(SUBSTITUTE($A2,CHAR(10),REPT(" ",100)),FIND(E$1,SUBSTITUTE($A2, CHAR(10), REPT(" ",100)))+LEN(E$1)+1,100)), "N/A")

    How does that work?

  14. #14
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    E2 works great. For the job Completion Notes, the formula works because you removed the additional "general job notes" wording from the cell. This is a practice sheet that I'm creating to use on very large sheets of data and I'll need one master formula to extract that data. Entering line breaks and removing parts of the text will have to be done manually cell by cell. I want the formula to do it for me.

    Also, cell M4 and N4 aren't finding the text in the deader for some reason. I made sure it's spelled the same but still.

    Thank you for your help.

  15. #15
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    The originals are too varied to do much better. I went back to your file in Post #8
    If you follow these steps it will be mostly good.
    Step 1
    Select Col A and hit CNTRL H to bring up Find/Replace Window
    Find: space [Alt + 010]
    Replace with: [Alt + 010]
    Keep hitting the replace All button until it comes up not found

    Step 2
    Clear the Find/Replace Windows
    Find: colon space
    Replace with: Colon
    repeat Replace All until no more

    Step 3
    Find: colon [Alt + 010]
    Replace with: colon

    In D2 copied down
    =TRIM(MID(A2, SEARCH($D$1&":",A2)+LEN($D$1)+2, SEARCH(CHAR(10)&CHAR(10),A2)-(SEARCH($D$1&":",A2)+LEN($D$1))))
    In E2 copied across and down
    =IFERROR(TRIM(MID(SUBSTITUTE($A2,CHAR(10),REPT(" ",100)),FIND(E$1,SUBSTITUTE($A2, CHAR(10), REPT(" ",100)))+LEN(E$1)+1,100)), "N/A")

    This is the result. Someone in Excel Programming Folder could macro this procedure.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    Amazing! The spreadsheet looks really good!

    There are two more minor issues. I don't understand the formula in it's entirety. It's just too complex for me.
    1) In Cells D3:D5, the first letter is omitted. Is that as easy fix?
    2) Cell N4 does not show the entire text from its section. It cuts off after "loop 1)"

  17. #17
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    For D3:D5 change that "+2" to "+1"

    For N4, I set the string lengths to 100 and that one is a whopping 358. I will play with it a bit

  18. #18
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    For the second formula starting in E2, change all the 100's to 400's. I checked and it doesn't affect any of the other results, just fixes N4

  19. #19
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    I really Appreciate it. This works Great!

  20. #20
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    When I plugged these formulas into the actual sheet I will be using, I ran into more issues. I attached the sheet below.

    Columns M and N are not seeing the header within the notes in column A so it's not returning the values. What to do?
    Attached Files Attached Files

  21. #21
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula for text extraction

    As I mentioned above, you need to do some find and replaces on Column A first
    I did 2
    1) Find ":ALT+10" (hitting Alt 010, not typing it)
    replace with : space
    2) find ": space ALT +10"
    Replace: ": space"
    Look better?
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    The spreadsheet definitely looks how I want it. I apologize, I'm not familiar with the find and replace function yet. I'm pretty new to excel. Would you describe in a little more detail how to go through the steps you described. How do you hit ALT 10?

  23. #23
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    Also, Is there a way to add that function into the formula? I am trying to create this for individuals who are only able to copy and paste the formula.

  24. #24
    Registered User
    Join Date
    06-22-2015
    Location
    Concord, CA
    MS-Off Ver
    2013
    Posts
    55

    Re: Formula for text extraction

    I keep trying but i cannot recreate what you did. I don't understand exactly what you did with find and replace

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with formula when I finish the result has vanished
    By GershD in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-16-2015, 02:12 PM
  2. Sumproduct formula:start to finish
    By Scotsman89 in forum Excel General
    Replies: 5
    Last Post: 07-14-2008, 10:45 AM
  3. Find The Tuesday (Finish The Formula!)
    By SamuelT in forum Excel General
    Replies: 2
    Last Post: 11-28-2007, 10:02 AM
  4. formula to lookup & sum totals, given a start inv.# & finish inv.#
    By Learning the hard way in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-21-2006, 07:55 AM
  5. [SOLVED] Finish Formula
    By Bobby in forum Excel General
    Replies: 5
    Last Post: 07-11-2005, 10:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1