Closed Thread
Results 1 to 4 of 4

VBA Extract Numbers only from Cell and Insert spaces Inbetween (Getnumbers)

  1. #1
    Registered User
    Join Date
    07-27-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    19

    VBA Extract Numbers only from Cell and Insert spaces Inbetween (Getnumbers)

    Hi All,

    I have been given the below bit of VBA from a friend to extract the numbers only from a cell (which works fine) but it extracts all the numbers and puts them all together without and spaces or delimiter which is a bit of a problem as i need to put each number that i extract into seperate cells (I was planning on doing this with text to coulms once i had them extracted)

    Please Login or Register  to view this content.
    Can any one help with this?

    Many thanks

    Jamie

  2. #2
    Registered User
    Join Date
    07-27-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: VBA Extract Numbers only from Cell and Insert spaces Inbetween (Getnumbers)

    I have been given this by my friend but i have no idea how to link it all together

    Getnumbers is a good start.

    I would have a look at split instead of looping through the string for the.

    e.g.
    This will split the cell content into small chunks delimited by the space, not tested but should work:
    Please Login or Register  to view this content.
    You can then repeat the above but use instr in order to find the location of each number.

    e.g.

    instr(split(getnumbers)(i),ctext,1,1)

    this will give you the numeric position of the number from which you can then do some string manipulation.

    newstring = left(oldstring,location_of_number-2) & "class " & mid(oldstring,location_of_number,2) & vcbcrlf & mid(oldstring,location_of_number+2)

    That should hopefully be enough to get you started

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

    Re: VBA Extract Numbers only from Cell and Insert spaces Inbetween (Getnumbers)

    try
    =GetAllNumbers(A1,", ")
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Extract Numbers only from Cell and Insert spaces Inbetween (Getnumbers)

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed 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