+ Reply to Thread
Results 1 to 18 of 18

Extracting Numbers from Text and turning the numbers into rows of data

Hybrid View

  1. #1
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Extracting Numbers from Text and turning the numbers into rows of data

    The format of the text in which I need to extract numbers is as follows:

    23411268 - 23411270

    Need to extract the following:

    23411268
    23411269
    23411270

    These numbers have to be listed in three seperate rows.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    With worksheet functions...

    A1 = your text string: 23411268 - 23411270
    B1 =LEFT(A1,FIND(" ",A1)-1)+0
    C1 =MID(A1,FIND("-",A1)+2,LEN(A1))+0

    A3 =IF(MAX($A$2:A2)=$C$1,"",MAX($A$2:A2,$B$1-1)+1)
    ...copy cell A3 down until the values stop appearing.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    It's a lot uglier to look at, but you could skip the B1 and C1 cells above by putting this formula in A3 and copying down:

    =IF(MAX($A$2:A2)=MID($A$1, FIND("-", $A$1)+2, LEN($A$1))+0, "", MAX($A$2:A2, LEFT($A$1, FIND(" ", $A$1)-1)-1)+1)

  4. #4
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Thanks for the formula. However do I need to change the formula if the text string seperator is different?

    ex: 2341145 / 2341146

    or 2341145 .. 2341147

    or 2341145..2341147

  5. #5
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    JB I noticed that your formula restricts itself to one cell location on the spreadsheet.

    What do you do when your string is in other areas of the spreadsheet, and you don't want to have to edit the formula constantly due to the new location of the text string?

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Gregg, the formula targets one cell and delivers the result. If other cells also need to be examined and processed the same way, then you will need to copy and edit the formula.

    Are you saying that the cell that will be examined is constantly changing position in the worksheet? If so, why? Or do you have several cells that you want to process? Could you provide some more context?

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

  8. #8
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Quote Originally Posted by Paul View Post
    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!
    Sorry about that I'm new to forum posting, and I'm not trying to upset anybody.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Quote Originally Posted by gregddd1 View Post
    Sorry about that I'm new to forum posting, and I'm not trying to upset anybody.
    If that's true, then realize we aren't kidding when we say to read through the Forum Rules so you can use and follow them effectively. Do that and all this correcting will go away.

  10. #10
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    The number of text strings to process is randomly positioned in different areas of the spreadsheet. Having to constantly edit the formula for each newly positioned text string slows me down considerably. I'm looking for a point and copy solution that negates the use of editing the formula due to a different cell address for the text string.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Quote Originally Posted by gregddd1 View Post
    The number of text strings to process is randomly positioned in different areas of the spreadsheet. Having to constantly edit the formula for each newly positioned text string slows me down considerably. I'm looking for a point and copy solution that negates the use of editing the formula due to a different cell address for the text string.
    You should start over here, then. You asked a too simple question. Also, you should consider some control on your end as well...saying you might have text strings separated by a variety of characters is unnecessarily complex, don't you think?

    To be able to "point" at anything and get a string of numbers would most likely:

    1) be a VBA solution
    2) require you to decide in advance all the different ways your two numbers will be separated and note them all so the macro can be trained
    3) decide in advance where these outputs are supposed to go each time you activate the macro

    Layout a full set of criteria and we'll try again. But think it all through, we're not on a design team here, we want to help but not drag this out forever, so a good complete set of criteria, method, end results...speed this whole thing along.

    Perhaps you can upload a sheet demonstrating ALL the variations you have to deal with, all the various places they might be, etc, and we can suggest something specific.

    Click GO ADVANCED and use the paperclip icon to post up your workbook.

  12. #12
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    See attached samples

    I have also posted this question on another forum, the url address is below:

    http://www.mrexcel.com/forum/showthread.php?t=450602
    Attached Files Attached Files
    Last edited by gregddd1; 02-25-2010 at 10:45 PM.

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Gregddd1, you still have not reacted to the cross post warning. Read the link in my signature and then act.

    Do not expect any answers on this thread until you have done so.

  14. #14
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    I have edited the previous post to include a cross-posted address.

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    I'm looking at post #11...3 questions and the sample workbook only sort of answers #2.

    The values can be anywhere in A:E? OK, so are they alone in these random cells or in the midst of longer strings? Should the macro willy-nilly check every cell in A:E or do you have a better thought about the selection method you haven't shared yet? Are there other values in A:E we have to carefully avoid changing? Any chance at all you can control the date input so the strings are consistent in one method instead of 6?

    And #3?

  16. #16
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    The text strings like the ones in the examples are the only text strings that needs to be converted, all other text strings need not be converted and can be ignored. Also, we're only talking about a max of 250 lines of these text strings that need to be converted per sheet.

    The result (numbers) of the conversion needs to go directly below the text string that is being converted. See below.

    2113456 - 2113460
    2113456
    2113457
    2113458
    2113459
    2113460

  17. #17
    Registered User
    Join Date
    02-23-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    Yes, the text strings could be anywhere in those columns.

    No, the 6 examples are the typical text strings I'm having to work with.

    The outputs are always directly below (in seperate rows) the text strings.

    Thanks so much for your help and patience with this problem of mine!

  18. #18
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extracting Numbers from Text and turning the numbers into rows of data

    The strings found are always far enough away from the next strings to put in numbers without moving anything? Like, if 10 numbers need to be put in, there would be nothing in the 10 rows beneath the found string?

+ 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