+ Reply to Thread
Results 1 to 14 of 14

Extract text between a character

Hybrid View

  1. #1
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Extract text between a character

    Looking for a formula that allows you to extract text between two characters.

    As an example, here we have the name of somebody, and how many whatever's they have.
    ";Jamie;3;Sarah;8;Simon;24;Lauren;5;"

    Then using this formula, the data would be put into a table. |Name|X of whatever's|
    Of course for what I'm really using this for, I don't want to just enter the data into a table because of formatting reasons.
    Last edited by Jake_1; 08-27-2018 at 11:42 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,461

    Re: Extract text between a character

    Can't you just use Data | Text-to-columns with ; as the delimiter?

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Re: Extract text between a character

    It does help however I found that still isn't exactly what I need.

    Example. At the moment I'm just using text to columns to convert something such as, "Small Laser;3" into "| Small Laser | 3 |".
    As I'd rather not have another table or something with expanded information on, I need a formula that checks and matches the "Weapon Name" to a list of other weapons. It then needs to (I assume) VLOOKUP that weapon, find it's damage per a second value then times it by the "Quantity" value.

    |Weapon Name|Quantity|Damage Per Second |
    |Small Laser |3 |This is where I need a formula|

    (the text that the table works off "Small Laser;3" isn't always the same amount of characters long, or the same order. I.e it could be "Large Laser;1;Small Railgun;8;Medium Cannon;3)

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,767

    Re: Extract text between a character

    Provide a set of sample data showing what you want the formula to return. 10-12 rows of representative data should be enough.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Re: Extract text between a character

    Screenshot_4.png
    Wasn't able to attach a document.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,767

    Re: Extract text between a character

    Can't work with a picture - sorry!

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  7. #7
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Re: Extract text between a character

    Thank you.
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,767

    Re: Extract text between a character

    Thanks. Which are the expected results that I asked you to add manually?

  9. #9
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Re: Extract text between a character

    Ah sorry, completely forgot. The expected results would be X*However many turrets are present. I.e Advanced Miner has 4 small mining lasers. So the end result would be 4*2.5

    2.5 being the value for one small mining laser.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,767

    Re: Extract text between a character

    Please add them manually to your workbook and attach again. You know what you want - I'm struggling to visualise it. Help us to help you!

  11. #11
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Re: Extract text between a character

    There we go.
    Attached Files Attached Files

  12. #12
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,461

    Re: Extract text between a character

    It is easier to split the multiple turrets into separate columns, so I have inserted 3 new columns and split column B with Text-to-columns using ; as the delimiter, as previously advised. I changed the headings for the new columns, and then you can use this formula in column F:

    =Table3[[#This Row],[QTY_1]]*VLOOKUP(Table3[[#This Row],[Turret_1]],Table2,2,0) + IFERROR(Table3[[#This Row],[QTY_2]]*VLOOKUP(Table3[[#This Row],[Turret_2]],Table2,2,0),0)

    The attached file shows the result.

    Hope this helps.

    Pete
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    09-16-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    43

    Re: Extract text between a character

    The problem with that is each ship can have up to 11 different weapons. So having 22 columns (plus the rest that I'm going to add in) is unnecessary. Having the formula that I'm looking for would significantly reduce that number.

  14. #14
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,461

    Re: Extract text between a character

    But your formula would become very long (and difficult to maintain). For example, for those records where you only have one weapon, then you could use this formula:

    =MID(Table3[[#This Row],[Turret(s)]],FIND(";",Table3[[#This Row],[Turret(s)]])+1,1) * VLOOKUP(LEFT(Table3[[#This Row],[Turret(s)]],FIND(";",Table3[[#This Row],[Turret(s)]])-1),Table2,2,0)

    Essentially, the MID part of this formula finds the number (assumes 1 character after the semicolon, but maybe this could be 2), then the VLOOKUP gets the appropriate value from Table2 for the weapon found on the left hand side of the semicolon.

    Where you have two or more weapons this wouldn't work, as you would need to find where the second semicolon is in order to extract the first weapon;number, and use that in the above formula, and then do this again for the second weapon;number pair, and repeat for up to 11 weapons.

    I'd certainly go for a simpler data layout and simpler formula - you could always hide the extra columns to retain the more condensed layout.

    Hope this helps.

    Pete

+ 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. Replies: 4
    Last Post: 08-13-2014, 11:03 PM
  2. How to extract 7 alphanumeric character from Text
    By hiteshkumar21483 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-24-2014, 03:43 AM
  3. [SOLVED] Extract text to left of nth character
    By cmb80 in forum Excel General
    Replies: 3
    Last Post: 06-16-2014, 11:09 AM
  4. [SOLVED] Extract text left and right of character
    By stuartm4h in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-12-2013, 07:32 AM
  5. Extract text after the LAST special character in a text string
    By phrankndonna in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-21-2013, 11:16 AM
  6. Extract Text up to Character
    By finlain in forum Excel General
    Replies: 2
    Last Post: 08-26-2009, 12:13 PM
  7. Extract the nth character in a string of text
    By Chopin in forum Excel General
    Replies: 2
    Last Post: 10-10-2006, 07:05 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