+ Reply to Thread
Results 1 to 14 of 14

Extract cell data before and including last number

  1. #1
    Registered User
    Join Date
    10-23-2022
    Location
    UK
    MS-Off Ver
    365 office
    Posts
    51

    Extract cell data before and including last number

    Hi

    Thanks in advance for your help

    I am looking for a formula which extracts the cell data before & including the last number

    Cheers


    RAW NM030RDL - REQUIRED OUTPUT NM030

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: Extract cell data before and including last number

    are all of your examples 3 on the left, then a space then the next 5?
    if so this will work for you... =MID(A2,5,5)
    however I have a suspicion that your data is more varied.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Extract cell data before and including last number

    Power Query Solution
    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    10-23-2022
    Location
    UK
    MS-Off Ver
    365 office
    Posts
    51

    Re: Extract cell data before and including last number

    Hi

    No it varies

    NM002HH
    NM0000001UU
    NM01111NT

  5. #5
    Registered User
    Join Date
    10-23-2022
    Location
    UK
    MS-Off Ver
    365 office
    Posts
    51

    Re: Extract cell data before and including last number

    Hi

    No it varies

    NM002HH
    NM0000001UU
    NM01111NT

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Extract cell data before and including last number

    Is that the raw data or the solution. Not clear what it represents. Suggest you read the yellow banner at the top of this page.

  7. #7
    Registered User
    Join Date
    10-23-2022
    Location
    UK
    MS-Off Ver
    365 office
    Posts
    51

    Re: Extract cell data before and including last number

    Hi

    Example sheet attached

    Thanks
    Attached Files Attached Files

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Extract cell data before and including last number

    Based on your latest

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-23-2022
    Location
    UK
    MS-Off Ver
    365 office
    Posts
    51

    Re: Extract cell data before and including last number

    Thanks, is that through power query? Is that supported in Google sheets, as this is where the raw data would sit

    Thanks

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,851

    Re: Extract cell data before and including last number

    It does not work in Google Sheets. That is something you should have mentioned in your first post and you should have posted it in the Google Section of the forum. I will move this for you. Please note this for the future. Your profile indicates 365 and not Google sheets. Also confusing.

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: Extract cell data before and including last number

    Hi Jacks,

    Alan used Power Query but here is a VBA solution that gives a user defined function (UDF) to reverse a string.
    Please Login or Register  to view this content.
    And I also use the newer Excel 365 function of "Sequence" to list digits from 0 to 9 and "TextBefore".
    The formula then looks like:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The file is in the attached below.
    VBA reverse to Trim After last Digit.xlsm

    Hope this helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: Extract cell data before and including last number

    Hi Jacks,

    Alan and I are Excel guys and I don't know if Google Sheets has all the features that MS Excel has. I really don't know if Sheets has "TextBefore", "Sequence" or a language like VBA behind it.

    If sheets has a Reverse String function then you can do it in my method. If you reverse the text string and find the first digit and take the text before that digit. Then find the length of these extra characters.

    Then use the entire length of the string minus the length found above in a Left() function to get your answer. I'm pretty sure Sheets has a basic Left() function. It might even have one that you could use if Right() looked from the rear??


  13. #13
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Extract cell data before and including last number

    For Google Sheets, try this;

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    10-23-2022
    Location
    UK
    MS-Off Ver
    365 office
    Posts
    51

    Re: Extract cell data before and including last number

    Thank you all for your help

    Haluk - the formula works perfect, thank you

    Cheers everyone

+ 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] Formula to extract a specific number from data in a cell
    By Doofus1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2020, 07:26 PM
  2. Extract data from cell starting from 1st number digit to end
    By DaanDean in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-13-2016, 07:39 AM
  3. Replies: 5
    Last Post: 02-01-2016, 05:57 PM
  4. [SOLVED] How to count the number of cells including data that are next to one another
    By timothy040888 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-24-2015, 10:07 AM
  5. [SOLVED] Remove everything in a Cell to the right of the first number, including that num
    By Trevasaurus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-05-2012, 01:26 AM
  6. [SOLVED] COUNT THE NUMBER OF LETTERS INCLUDING SPACES IN A CELL?
    By zurafz6 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-06-2006, 04:00 AM
  7. Replies: 2
    Last Post: 01-27-2006, 03:35 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