+ Reply to Thread
Results 1 to 7 of 7

Return text 'around' the x

  1. #1
    Registered User
    Join Date
    03-22-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    40

    Return text 'around' the x

    Hi,

    I am familiar with left, right, mid, len etc. But now I have a column with very inconsistent data and I have to extract the text 'around' the X. So recognize the x and then return what's between spaces.

    E.g.
    • Hello Pocket Hr Yes medium 90x210 >>> return >>> 90x210
    • Pillow according to 161x47x8 according to rules >>> return >>> 161x47x8
    • pocket, AA10, 1.6/1.8, Medium, 100x200 >>> return >>> 100x200
    • Cover 180x200, core 19 >>> return >>> 180x200
    • Pocket 40 HALLO 90x210x22 (2x 4,5cm) ATTENTION HAS EXCEPTION >>> return >>> 90x210x22

    Hope someone know how to do the trick! Thanks.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,222

    Re: Return text 'around' the x

    so expected results are

    90 and 120 from 90x120

  3. #3
    Registered User
    Join Date
    03-22-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    40

    Re: Return text 'around' the x

    Hello Pocket Hr Yes medium 90x210 should return 90x120
    for example.

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Return text 'around' the x

    try this
    in the adjacent cell and drag down
    =TRIM(RIGHT(SUBSTITUTE(TRIM(A1), " ", REPT(" ", LEN(TRIM(A1)))),LEN(TRIM(A1))))
    Teach me Excel VBA

  5. #5
    Registered User
    Join Date
    03-22-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    40

    Re: Return text 'around' the x

    Thanks Imran, unfortunately this only works if the sizes are to be found on the right, now when they are in the middle.... Thanks though.

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Return text 'around' the x

    Sorry I thought the result is the last word
    try this

    add a helper column say B
    type this formula in B1
    =A1&" "
    then in C1 type
    = RIGHT(SUBSTITUTE(TRIM(LEFT(B3,FIND(" ",B3,FIND("x",B3)))&" "), " ", REPT(" ", LEN(TRIM(LEFT(B3,FIND(" ",B3,FIND("x",B3)))&" ")))),LEN(TRIM(LEFT(B3,FIND(" ",B3,FIND("x",B3)))& " ")))
    and copy down

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

    Re: Return text 'around' the x

    Try below array formula in B1 and copy towards down, assume that your data in Cell A1
    Please Login or Register  to view this content.
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Samba

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

+ 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. If cell contains certain text and certain text then return predefined text
    By fuzzhead in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-25-2014, 02:18 PM
  2. [SOLVED] How to match a cell with text with a range of text and return own text
    By ec4excel in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-16-2014, 11:07 AM
  3. Formula to find and return text string within a cell full of text strings
    By LightingPop in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-03-2013, 11:45 PM
  4. [SOLVED] function IF to return text based if text contains exact text
    By in nomine noctis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-05-2013, 06:25 AM
  5. Replies: 2
    Last Post: 09-07-2013, 07:50 PM
  6. If cell contains text1, text2 or text 3 return this text, otherwise return X
    By bukmanodrama in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-26-2013, 09:24 AM
  7. Replies: 7
    Last Post: 01-24-2013, 06:55 PM

Tags for this Thread

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