+ Reply to Thread
Results 1 to 11 of 11

Removing Text and Leaving just numbers

  1. #1
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Removing Text and Leaving just numbers

    hey guys

    i have a sheet dealing with part numbers and a paramiter exported from a programme.

    L=1000MM | L/R is an example.

    now
    i use replace to get rid of everything before the number but anything after the mm is totaly different most of the time.
    is there a way that i can get rind of anything after, and including, the mm?
    or by some chance a command that will just leave me with the number allone??

    Ps: sorry about the title before was totaly incorrect
    Last edited by FRIEL; 02-16-2009 at 05:53 AM. Reason: wrong title
    I dont like to use code i dont understand
    it makes it hard to use in other situations
    so please try to be as clear and patent as possible with me

    Criticism is welcomed

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Removing Text and Leaving just numbers

    A sample would be helpful in this instance such that we can determine the ranges in play etc... presumably you're looking to replace the actual value in the same cell... else you could use formulae in an adjacent cell.

  3. #3
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Re: Removing Text and Leaving just numbers

    a full example would be a bit large and over complicated
    but i have attached somthing that i think gets what i am after
    no i am looking to keep the cell as is
    but the number is a length i need to multiply by a price per mm.
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Removing Text and Leaving just numbers

    Perhaps:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Re: Removing Text and Leaving just numbers

    no i need it in visual basic

  6. #6
    Registered User
    Join Date
    05-02-2004
    MS-Off Ver
    2007
    Posts
    43

    Re: Removing Text and Leaving just numbers

    Have a look at InStr then it is the VBA version of Find().

    TJ

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Removing Text and Leaving just numbers

    Using your approach (not mine I should add)

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Re: Removing Text and Leaving just numbers

    hmm
    sounds like u have a better idea than me
    i am always open to learning a few things
    i am self taught in vba from sites like these so i can be a little sloppy at times

  9. #9
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Re: Removing Text and Leaving just numbers

    thanks for that DonkeyOte

    works just how i wanted it to
    any chance of explaining the split and val functions to me ive had a look and cant quite figure it out

    val seems to return the numbers at the start of a string
    is that right??

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Removing Text and Leaving just numbers

    The Split will split the string based on the Delimiter specified.

    Assuming then a string of:

    Please Login or Register  to view this content.
    Then

    Please Login or Register  to view this content.
    Will generate 2 substrings (0 & 1):

    Please Login or Register  to view this content.
    Thus Split(str,"=")(1) refers to the 2nd sub string

    Please Login or Register  to view this content.
    thus returns 1000 -- it will stop reading as soon as it finds a non-numeric character (period character excepted)

  11. #11
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266

    Re: Removing Text and Leaving just numbers

    that was exactly what i wanted
    well put
    thanks alot

+ 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