+ Reply to Thread
Results 1 to 14 of 14

Exctract numbers after a cell reference

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Exctract numbers after a cell reference

    Hi Excel Forum world,

    I am having trouble cracking this one! I have a situation where a client wants me to extract all prefixes to an address column"

    What I have so far is:


    E2 = "Level 5, Test Street"

    C2 = "Level" (extracted from E2)

    D2 = Needs to display "Level 5," using C2 as a reference because this value changes down column C and could say Unit, Apartment etc.

    Can anyone suggest a way I can do this with either formula or VBA?

    Many thanks,
    Brendan

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Exctract numbers after a cell reference

    Assuming that the level number in E2 will always be followed by a comma, the following formulas seem to work:
    In C2: ="Level "&MID(E2,FIND(",",E2)-2,2)
    In D2: =C2
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Exctract numbers after a cell reference

    Hi JeteMc,
    Thanks for the reply!

    This almost works except for a few issues:

    1. The number may not follow a comma and there may be other commas in the address so finding a comma will not work.
    2. the value in column C is found using an INDEX, MATCH so it will not always be Level and it may be blank.

    Here are a few examples:

    11 Harbour Street, Darling Quarter, Level 1, South Building
    - Needs to return Level 1


    19 Herbert St, Unit 10
    - Needs to return Unit 10

  4. #4
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Exctract numbers after a cell reference

    Also the number will not always be 2 digits.

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Exctract numbers after a cell reference

    I suggest uploading a sample spreadsheet with examples of types of input that could possibly be found in column E along with expected outputs in columns C and D.
    To attach a sample spreadsheet click on the GO ADVANCED button below the Quick Reply window and then scroll down to Manage Attachments to open the upload window.
    Let us know if you have any questions.

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

    Re: Exctract numbers after a cell reference

    Just a demo
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Exctract numbers after a cell reference

    Test Doc attached
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Exctract numbers after a cell reference

    Paste the following formula into D2, press the enter key and double click the fill handle to copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  9. #9
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Exctract numbers after a cell reference

    Thanks mate this almost worked perfectly, just a few issues.

    There are some addresses that do not adhere to a standard convention that are not being picked up correctly in the return.
    The issues are in the attached document but this is the list of reasons I can see it not working:
    • Unit number before slash
    • No separator at all
    • Unit number before dash
    • Unit number at end of address
    • Comma after full street address
    • Number before slash but word apartment elsewhere in address
    • Ground Level


    I know this a lot of variables but I am hoping that there is way that you can have the formula pick up only:

    1. The unit type
    2. The numbers After the unit type and Before the next space.


    Thanks for your help.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Exctract numbers after a cell reference

    Hi JeteMc,

    Do you think that my below request can be done?

    Thanks again for your help so far.

  11. #11
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Exctract numbers after a cell reference

    I will show you what I have come up with so far, it doesn't find all of them, but does find some.
    The formula employed is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Perhaps someone on the VBA side will take another look at the file attached to post #9.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Exctract numbers after a cell reference

    Thanks very much this is great and addresses most of the .... addresses!

  13. #13
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Exctract numbers after a cell reference

    I attacked this from another direction, five helper columns (which may be hidden for aesthetic purposes). The first helper (AB) sets the starting point for the number to be extracted using the array entered formula*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The second through fourth helpers (AC:AF) are similar using variations of the formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Finally the formula that populates column D is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Array entered formulas are activated by simultaneously pressing the Ctrl, Shift and Enter keys while the cell is still in edit mode.
    More helper columns could be added if the largest number to be extracted has more than 4 digits.
    Note: Attempted to address the issue in row 34 (/ and apartment) by rearranging the order of the Lists sheet column A.
    Let us know if you have any questions.
    Attached Files Attached Files

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,556

    Re: Exctract numbers after a cell reference

    Once more.
    Deleted the formula from columns AC:AF of the post above and instead used the following array entered formula* in AC:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Where Lists!C$2:C$4 references the list of separators: Space, Period and Slash
    The formula that populates column D is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Seems to do better getting addresses such as the ones in rows 15, 31 and 43.
    Let us know if you have any questions.
    Attached Files Attached Files

+ 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. Exctract lines in sheet to another sheet based on text/names in cell
    By Generalist in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-12-2016, 08:32 AM
  2. Text and numbers in one cell to reference in another cell on a separate sheet
    By meltshop85 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-25-2014, 12:56 AM
  3. Replies: 1
    Last Post: 08-22-2014, 08:25 AM
  4. [SOLVED] Macro to copy cell contents (a website) -> paste in exctract external data url address box
    By kak0 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-31-2014, 05:20 PM
  5. [SOLVED] How can I exctract numbers from a string of characters in a separate column ?
    By Renzo Isola in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-27-2013, 11:15 PM
  6. Adding cell reference numbers together
    By mickeymorris626 in forum Excel General
    Replies: 5
    Last Post: 05-05-2011, 01:06 PM
  7. how exctract words within bracket
    By njan1982 in forum Excel General
    Replies: 1
    Last Post: 12-02-2008, 05:07 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