+ Reply to Thread
Results 1 to 5 of 5

RIGHT/LEFT/MID Functions

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    chapel hill, NC
    MS-Off Ver
    Excel 2010
    Posts
    29

    RIGHT/LEFT/MID Functions

    So for a project, I have this as my text in cell A2:

    <table id="nolines">

    I am supposed to have the value of nolines, without anything else.

    The formula:

    =RIGHT(A2,LEN(A2)-FIND("""",A2)) is returning nolines"> and I cannot figure this out! Any help would be great.

  2. #2
    Forum Contributor
    Join Date
    03-11-2013
    Location
    Michigan
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: RIGHT/LEFT/MID Functions

    =left(right(a2,9),7)

  3. #3
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: RIGHT/LEFT/MID Functions

    =MID(A2,FIND("""",A2)+1,FIND(">",A12)-FIND("""",A2)-2)

    This should do the job for you.

    Your original formula could also be modified to do this to:
    =LEFT(RIGHT(A2,LEN(A2)-FIND("""",A2)),LEN(RIGHT(A2,LEN(A2)-FIND("""",A2)))-2)
    Say thanks, click *

  4. #4
    Registered User
    Join Date
    04-18-2013
    Location
    chapel hill, NC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: RIGHT/LEFT/MID Functions

    Thanks to the both of you.

    I responded to the first post, but I'm not sure it went through. Can either of you care to explain the intuition behind your formulas? It would help me very much moving forward.

  5. #5
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: RIGHT/LEFT/MID Functions

    To understnad formulas you start from the inside out. So for cheal2's formula =left(right(a2,9),7) you need to fist understand:

    right(a2,9)
    This will display text from A2 9 characters from the right = nolines">
    Then the left(X,7) part kicks in. Note X has been evaluated to nolines"> so you can say the formula is now =left(nolines">,7)

    This takes the text nolines"> and shows the first 7 characters = nolines
    The only disadvantage to this method is that it assumes you always have the same text layout in A2.

    My formula (which I believe can be tidied up but i'm not 100% with text manipulation) will return any text within the " bracket (assuming that the second " is followed by a >).

    Breakdown:
    =MID(A2,FIND("""",A2)+1,FIND(">",A12)-FIND("""",A2)-2) whole formula

    FIND("""",A2)+1 returns the location on the first " in A2 and adds 1. Adding 1 is used because you don't want to include the " in your output.

    This gives:
    =MID(A2,12,FIND(">",A12)-12-2)

    FIND(">",A12) is used to find the location of > so the formula can now be looked at as:
    =MID(A2,12,20-12-2)

    The mid formula needs to know the cell to look at (A2) the first character location you want to start at (12) and the number of characters from the start location to show (20-12-2).
    The 20 is the location of > in A2, -12 is the start number and -2 is because you want to exclude the "> from the end.

    The advantage of this formula is that you can enter any text into A2 and get the required output, eg:

    <table id="nolines"> would become nolines
    <something else instead ="resulting text to show"> would become resulting text to show

    I hope that makes sense, I always find it hard to explain how things work!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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