+ Reply to Thread
Results 1 to 17 of 17

Search a specific character if meet look for another then extract data

  1. #1
    Registered User
    Join Date
    03-28-2008
    Posts
    17

    Red face Search a specific character if meet look for another then extract data

    Hi

    I have a field with the similar data like following.

    {\rtf1\deff0{\fonttbl{\f0 Courier New;}}\sectd\pard\plain\ql{\cf0 FUTEK F3000 SIDM Printer }\par\pard\plain\ql{\cf0 WITH 6 YEARS WARRANTY FOR PRINTER}\par }

    I need a formula to search if the field have the specify character 'warranty' then look for position of '{' and '}' within the block to extra the data '\cf0 WITH 6 YEARS WARRANTY FOR PRINTER' to another cell.

    The position maybe different for rows.

    Any help is greatly appreciated.

  2. #2
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Search a specific character if meet look for another then extract data

    Does the text fragment \cf0 WITH 6 YEARS WARRANTY FOR PRINTER is always the same length? If so, I believe this solution might work.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-28-2008
    Posts
    17

    Re: Search a specific character if meet look for another then extract data

    No all rows have the same length and the position maybe different.

  4. #4
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Search a specific character if meet look for another then extract data

    I understood the position of the fragment may be different, what I asked was is the length of the fragment itself always the same? Is the fragment always in this format \cf0 WITH 6 YEARS WARRANTY FOR PRINTER? And not this \cf0 6 YEARS WARRANTY FOR PRINTER? Or this \cf0 WITH 6 YEARS WARRANTY?

    If the fragment is always the same length, it doesn't matter where it is located. My formula finds the end phrase ("PRINTER}"), then substracts the necessary number of characters (which is 31 in this case) from the position and returns the whole phrase. For this approach, the position of the text fragment is irrelevant, what matters is that it always has the same amount of characters.

  5. #5
    Registered User
    Join Date
    03-28-2008
    Posts
    17

    Re: Search a specific character if meet look for another then extract data

    Hi Bmouse,

    Thank you for the formula. I have attached mydata with the formula, it seem not applicable for all.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Search a specific character if meet look for another then extract data

    Ok, so the fragment itself differs in length, which means a different solution is necessary.

  7. #7
    Registered User
    Join Date
    03-28-2008
    Posts
    17

    Re: Search a specific character if meet look for another then extract data

    Actually the formula should search 'warranty' from the long text. Then go front and look for { sign and behind for } sign. Extract data start with { with the specify character 'warranty' in the block. End when the } sign then.

  8. #8
    Registered User
    Join Date
    03-28-2008
    Posts
    17

    Re: Search a specific character if meet look for another then extract data

    Hi

    can the excel VBA handling the datas?

  9. #9
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Search a specific character if meet look for another then extract data

    You can search for the word "WARRANTY" and get the position number, then use that number to find the "}" sign at the end of the phrase. What I can't figure out is how to find the start number of the phrase, because the phrases are not all the same. Even if you find the "WARRANTY" and the end sign "}" you have no idea where the phrase starts. I tried searching for the "\cf0", but there are multiple of those, so thats a no go.

    Nothing associated with VBA comes to mind too.

  10. #10
    Registered User
    Join Date
    07-09-2012
    Location
    India
    MS-Off Ver
    Excel 97/2003/2007/2010
    Posts
    67

    Re: Search a specific character if meet look for another then extract data

    Hi seolann,

    =left(mid(k8,find("with",k8,1),99),find("}",mid(k8,find("with",k8,1),99),1)-1)

    try this .....

    Let me know where you stuck... I didnt read all others comments...

    Sathya

  11. #11
    Registered User
    Join Date
    07-09-2012
    Location
    India
    MS-Off Ver
    Excel 97/2003/2007/2010
    Posts
    67

    Re: Search a specific character if meet look for another then extract data

    Hi,

    try this for latest sheet

    =left(mid(a2,find("with",a2,1),99),find("}",mid(a2,find("with",a2,1),99),1)-1)

  12. #12
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Search a specific character if meet look for another then extract data

    The formula itself works, I just had to change the commas to semicolons because of my region, however it does not provide the necessary result. The word "with" is not always used in the target phrase, hence no cigar. That is the main problem here - the only word all of the phrases contain is "warranty" (and also "year") but they differ in lenghth and structure.

    Actually, if you change the word "with" to "warranty" it gives YEARS WARRANTY FOR PRINTER, only the starting position is off as \cf0 WITH 6 YEARS WARRANTY FOR PRINTER is the expected result. What else could be done with the formula to adjust the starting position of the phrase?

  13. #13
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Search a specific character if meet look for another then extract data

    =MID(A2,LOOKUP(SEARCH("WARRANTY",A2),IF(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),4)="\cf0",ROW(INDIRECT("1:"&LEN(A2)))),IF(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),4)="\cf0",ROW(INDIRECT("1:"&LEN(A2))))),FIND("}\",A2,SEARCH("WARRANTY",A2))-LOOKUP(SEARCH("WARRANTY",A2),IF(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),4)="\cf0",ROW(INDIRECT("1:"&LEN(A2)))),IF(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),4)="\cf0",ROW(INDIRECT("1:"&LEN(A2))))))
    Try this array formula
    shift+ctrl+enter
    Attached Files Attached Files
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  14. #14
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Search a specific character if meet look for another then extract data

    This one is definitely going in my book as one of the longest formulas ever seen

    Nice work nflsales

  15. #15
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Search a specific character if meet look for another then extract data

    thanks bmouse
    B2 =TRIM(MID(SUBSTITUTE(SUBSTITUTE(A2,"\cf0",REPT(" ",LEN(A2))&"\cf0"),"}\",REPT(" ",LEN(A2))),SEARCH("WARRANTY",SUBSTITUTE(SUBSTITUTE(A2,"\cf0",REPT(" ",LEN(A2))&"\cf0"),"}\",REPT(" ",LEN(A2))))-LEN(A2),LEN(A2)*2))
    try this and copy towards down

  16. #16
    Registered User
    Join Date
    03-28-2008
    Posts
    17

    Re: Search a specific character if meet look for another then extract data

    Thanks all,

    The above formula work. Thank all the great effort!

  17. #17
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Search a specific character if meet look for another then extract data

    Thanks for your feedback

+ 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. [SOLVED] Search & extract cell data, after & before specific values with a formula
    By lagiosman in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-20-2014, 09:03 AM
  2. [SOLVED] Extract multiples records from adatabase which meet a specific condition
    By Danny77 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-22-2013, 09:05 AM
  3. [SOLVED] Extract a part from cell behind a specific character
    By Marco-Kun in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-22-2012, 03:02 PM
  4. Replies: 7
    Last Post: 03-29-2012, 01:25 PM
  5. Formula to search a cell for specific data to extract
    By AK262007 in forum Excel General
    Replies: 4
    Last Post: 03-13-2009, 10:37 AM

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