+ Reply to Thread
Results 1 to 14 of 14

Extract Number with Prefix from Text

  1. #1
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Extract Number with Prefix from Text

    Hello dear Forum Members,

    I am trying to extract All numbers with a Prefix of "E" in a Column. All numbers will always be E12345 or E and 5 numbers. I got it to work somehow as shown in the attached sample Workbook, but there appears extracted numbers which are not correct.

    Would anybody be able to assist me with this?

    Thank you!
    Attached Files Attached Files
    Happy? Click the * to the left.

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,203

    Re: Extract Number with Prefix from Text

    Try this:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,060

    Re: Extract Number with Prefix from Text

    You could also use RegEx:

    Please Login or Register  to view this content.
    Last edited by romperstomper; 02-24-2020 at 05:54 AM.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Re: Extract Number with Prefix from Text

    @ Phuocam,

    Thank you for your time and help. Unfortunately your Function does not include the "e" with the Extracted number, which is what I ideally want.

    Do you perhaps have a workaround for this, and have the Code not to be Case Sensitive regarding the "E"?

    Many thanks!

  5. #5
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Re: Extract Number with Prefix from Text

    @ rorya,

    Many thanks for your time and help as well. Your Code is Case Sensitive which I would like to avoid. Your Function also ignores any number which is followed with Text without a space after the number.

    Sorry to bother you guys with these issues, but I would really appreciate it if you could solve these few glitches.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,060

    Re: Extract Number with Prefix from Text

    Change the function to:

    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Extract Number with Prefix from Text

    If you don't want to extract E with more than 5 numbers then try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Re: Extract Number with Prefix from Text

    @ rorya,

    JACKPOT!!! Absolutely awesome! Kudos to you. That is brilliant!

    Thank you for your time and help, I appreciate it.
    Rep added!

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,060

    Re: Extract Number with Prefix from Text

    Glad to help, and thanks for the rep.

    I'd recommend looking at the pattern in Jindon's version if you might have Ennnnn as part of another number that should be ignored.

  10. #10
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,203

    Re: Extract Number with Prefix from Text

    Try the following code:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Re: Extract Number with Prefix from Text

    Thank you jindon!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Extract Number with Prefix from Text

    You are welcome and thanks for the rep.

    Don't forget to mark the thread as solved...

  13. #13
    Registered User
    Join Date
    02-22-2016
    Location
    Harare, Zimbabwe
    MS-Off Ver
    2007 & 2010
    Posts
    71

    Re: Extract Number with Prefix from Text

    Hello Guys,

    My original requirement for looking at 5 Numbers only, has changed to Any number of integers after a prefix which is selected from a Drop Down Cell. I wish to also include the number of integers to look for via a Drop Down Cell in Cell L1.

    Please see the attached sample Workbook which better shows my requirement.

    Thanks!

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Extract Number with Prefix from Text

    1) Replace "Function GetNumWithPref" with
    Please Login or Register  to view this content.
    2) Replace below one line in "Sub ExpNumbers()"
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

+ 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] add prefix to number based on validation from other data if found prefix 0, do nothing
    By oeyandyprawira in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2018, 11:52 AM
  2. [SOLVED] Extract Multi-line Data Based on prefix and format
    By chilli16 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2018, 11:15 AM
  3. [SOLVED] Extract Multi-line Data Based on prefix
    By chilli16 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-29-2018, 05:15 AM
  4. [SOLVED] Incrementing a cell value that has a text prefix and number
    By RM05067 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2016, 03:33 AM
  5. [SOLVED] Extract certain text dependant on number of characters in text
    By bjoanmark in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-28-2014, 02:57 AM
  6. creating sequential number with text prefix
    By j_r_m_c in forum Excel General
    Replies: 3
    Last Post: 07-04-2014, 09:42 AM
  7. Extract Numbers and prefix letter
    By aromaveda in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-22-2009, 09:00 PM

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